From 3131e93b925f06f183965ef72690d01810b5873e Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Tue, 2 Sep 2014 23:11:23 +0200 Subject: added memoization to config lookup in eclipse. This should help make it (much) faster. --- src/core/lombok/eclipse/EclipseAST.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/core') diff --git a/src/core/lombok/eclipse/EclipseAST.java b/src/core/lombok/eclipse/EclipseAST.java index 5723668b..6df5c4d7 100644 --- a/src/core/lombok/eclipse/EclipseAST.java +++ b/src/core/lombok/eclipse/EclipseAST.java @@ -70,7 +70,18 @@ public class EclipseAST extends AST { } private static volatile boolean skipEclipseWorkspaceBasedFileResolver = false; + private static final URI NOT_CALCULATED_MARKER = URI.create("http://projectlombok.org/not/calculated"); + private URI memoizedAbsoluteFileLocation = NOT_CALCULATED_MARKER; + public URI getAbsoluteFileLocation() { + if (memoizedAbsoluteFileLocation != NOT_CALCULATED_MARKER) return memoizedAbsoluteFileLocation; + + memoizedAbsoluteFileLocation = getAbsoluteFileLocation0(); + return memoizedAbsoluteFileLocation; + } + + /** This is the call, but we wrapped it to memoize this. */ + private URI getAbsoluteFileLocation0() { String fileName = getFileName(); if (fileName != null && (fileName.startsWith("file:") || fileName.startsWith("sourcecontrol:"))) { // Some exotic build systems get real fancy with filenames. Known culprits: -- cgit