From ea0fbd8ca511ae3ab336b166b34b273a8b2c1366 Mon Sep 17 00:00:00 2001 From: Christoph Dreis Date: Wed, 22 Feb 2023 14:03:58 +0100 Subject: Cache ConfigurationFile.parent() --- src/core/lombok/core/configuration/ConfigurationFile.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/lombok/core/configuration/ConfigurationFile.java b/src/core/lombok/core/configuration/ConfigurationFile.java index 9a5e97e3..8e4e687c 100644 --- a/src/core/lombok/core/configuration/ConfigurationFile.java +++ b/src/core/lombok/core/configuration/ConfigurationFile.java @@ -110,7 +110,8 @@ public abstract class ConfigurationFile { private static class RegularConfigurationFile extends ConfigurationFile { private final File file; - + private ConfigurationFile parent; + private RegularConfigurationFile(File file) { super(file.getPath()); this.file = file; @@ -173,8 +174,11 @@ public abstract class ConfigurationFile { } @Override ConfigurationFile parent() { - File parent = file.getParentFile().getParentFile(); - return parent == null ? null : forDirectory(parent); + if (parent == null) { + File parentFile = file.getParentFile().getParentFile(); + parent = parentFile == null ? null : forDirectory(parentFile); + } + return parent; } private static String replaceEnvironmentVariables(String fileName) { -- cgit