| Summary: | Micro-optimization : don't call consumedComponent.getRootFolder() twice in FlatVirtualComponent.consumeComponent(...) | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [WebTools] WTP Common Tools | Reporter: | Fred Bricon <fbricon> | ||||
| Component: | wst.common | Assignee: | Rob Stryker <stryker> | ||||
| Status: | RESOLVED FIXED | QA Contact: | Carl Anderson <ccc> | ||||
| Severity: | minor | ||||||
| Priority: | P3 | CC: | cbridgha, stryker | ||||
| Version: | unspecified | ||||||
| Target Milestone: | 3.4 M5 | ||||||
| Hardware: | PC | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 209606 [details]
Micro-optipatch ;)
Patch as per the comments by fred
I like the change - thanks! Committed and released to head and 3.3.2 |
Build Identifier: 20110916-0149 m2e-wtp uses a custom IVirtualComponent, OverlayVirtualComponent, to handle War Overlays à-la-Maven. OverlayVirtualComponent.getRootFolder() method is somewhat slow, as it treewalks the overlay graph to build it's resource tree -It may be a BAD thing, but that's not really the point-. However, I see that getRootFolder() method is called way more than necessary. Turns out the current FlatVirtualComponent.consumeComponent(...) calls it twice, as you can see : protected void consumeComponent(VirtualComponentFlattenUtility util, IPath root, IVirtualReference reference) throws CoreException { IVirtualComponent consumedComponent = reference.getReferencedComponent(); if (consumedComponent.getRootFolder()!=null) { IVirtualFolder vFolder = consumedComponent.getRootFolder(); util.addMembers(consumedComponent, vFolder, root.append(reference.getRuntimePath().makeRelative())); addConsumedReferences(util, consumedComponent, root.append(reference.getRuntimePath().makeRelative())); addUsedReferences(util, consumedComponent, root.append(reference.getRuntimePath().makeRelative())); } } I think it can safely be refactored to : protected void consumeComponent(VirtualComponentFlattenUtility util, IPath root, IVirtualReference reference) throws CoreException { IVirtualComponent consumedComponent = reference.getReferencedComponent(); IVirtualFolder vFolder = consumedComponent.getRootFolder(); if (vFolder!=null) { util.addMembers(consumedComponent, vFolder, root.append(reference.getRuntimePath().makeRelative())); addConsumedReferences(util, consumedComponent, root.append(reference.getRuntimePath().makeRelative())); addUsedReferences(util, consumedComponent, root.append(reference.getRuntimePath().makeRelative())); } } Reproducible: Always