From 4003a445c791921ec2b8065cf1a9202997f16585 Mon Sep 17 00:00:00 2001 From: Martin Panzer Date: Thu, 23 Dec 2021 09:36:39 +0100 Subject: [PATCH] Save the result of Path.toUri() Converting a path multiple times to its URI representation is costly. This call can easily be cached for the sysfs path to the zip, since paths themselves are immutable. --- src/main/java/io/quarkus/fs/util/base/DelegatingPath.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/quarkus/fs/util/base/DelegatingPath.java b/src/main/java/io/quarkus/fs/util/base/DelegatingPath.java index e30d47b..0a72166 100644 --- a/src/main/java/io/quarkus/fs/util/base/DelegatingPath.java +++ b/src/main/java/io/quarkus/fs/util/base/DelegatingPath.java @@ -21,8 +21,9 @@ public abstract class DelegatingPath implements Path { protected final Path delegate; + private volatile URI uri; + /** - * * @param delegate the Path to delegate to. May not be null. */ protected DelegatingPath(Path delegate) { @@ -155,7 +156,10 @@ public Path relativize(Path other) { @Override public URI toUri() { - return delegate.toUri(); + if (uri == null) { + uri = delegate.toUri(); + } + return uri; } @Override