diff options
author | aclement <aclement> | 2008-08-23 04:19:03 +0000 |
---|---|---|
committer | aclement <aclement> | 2008-08-23 04:19:03 +0000 |
commit | 243afc5c6e1a76a0e9cead7894ab3765581adc04 (patch) | |
tree | a4a38a4b01942373f54a7b53e8af303240a41786 /asm | |
parent | b4799d333afa2f8be94f0e947b27c40a957d541d (diff) | |
download | aspectj-243afc5c6e1a76a0e9cead7894ab3765581adc04.tar.gz aspectj-243afc5c6e1a76a0e9cead7894ab3765581adc04.zip |
243376: optimized searching for handles
Diffstat (limited to 'asm')
-rw-r--r-- | asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java b/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java index 31aad3f18..43a43c7d6 100644 --- a/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java +++ b/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java @@ -342,27 +342,33 @@ public class AspectJElementHierarchy implements IHierarchy { // findElementForHandle() to mirror behaviour before pr141730 private IProgramElement findElementForHandleOrCreate(String handle, boolean create) { // try the cache first... - IProgramElement ret = (IProgramElement) handleMap.get(handle); - if (ret != null) return ret; + IProgramElement ipe = (IProgramElement) handleMap.get(handle); + if (ipe != null) { + return ipe; + } - ret = findElementForHandle(root,handle); - if (ret == null && create) { - ret = createFileStructureNode(getFilename(handle)); + ipe = findElementForHandle(root,handle); + if (ipe == null && create) { + ipe = createFileStructureNode(getFilename(handle)); } - if (ret != null) { - cache(handle,(ProgramElement)ret); + if (ipe != null) { + cache(handle,ipe); } - return ret; + return ipe; } private IProgramElement findElementForHandle(IProgramElement parent, String handle) { for (Iterator it = parent.getChildren().iterator(); it.hasNext(); ) { IProgramElement node = (IProgramElement)it.next(); - if (handle.equals(node.getHandleIdentifier())) { + String nodeHid = node.getHandleIdentifier(); + if (handle.equals(nodeHid)) { return node; } else { - IProgramElement childSearch = findElementForHandle(node,handle); - if (childSearch != null) return childSearch; + if (handle.startsWith(nodeHid)) { + // it must be down here if it is anywhere + IProgramElement childSearch = findElementForHandle(node,handle); + if (childSearch != null) return childSearch; + } } } return null; |