Bug 153812 - [performance] [deployables] Redundant existance checks in J2EEFlexProjDeployable.members()
Summary: [performance] [deployables] Redundant existance checks in J2EEFlexProjDeploya...
Status: CLOSED FIXED
Alias: None
Product: WTP Java EE Tools
Classification: WebTools
Component: jst.j2ee (show other bugs)
Version: 1.5   Edit
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: 1.5.1 M151   Edit
Assignee: John Lanuti CLA
QA Contact: Chuck Bridgham CLA
URL:
Whiteboard: review
Keywords: performance
Depends on:
Blocks:
 
Reported: 2006-08-14 15:17 EDT by Jeffrey Liu CLA
Modified: 2006-09-21 14:25 EDT (History)
1 user (show)

See Also:


Attachments
Proposed patch (2.11 KB, patch)
2006-08-15 14:50 EDT, John Lanuti CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeffrey Liu CLA 2006-08-14 15:17:32 EDT
In J2EEFlexProjDeployable.members()...

IVirtualComponent vc = ComponentCore.createComponent(getProject());
if (vc != null) {
        IVirtualFolder vFolder = vc.getRootFolder();
        IModuleResource[] mr = getMembers(vFolder, Path.EMPTY);
        int size = mr.length;
        for (int j = 0; j < size; j++) {
                if (!members.contains(mr[j]))  // <------- check for existence
                        members.add(mr[j]);
        }
}

IContainer[] javaCont = getJavaOutputFolders();         
int size = javaCont.length;
for (int i = 0; i < size; i++) {
        IModuleResource[] mr = getMembers(javaCont[i], javaPath, javaPath,
javaCont);
        int size2 = mr.length;
        for (int j = 0; j < size2; j++) {
                if (!members.contains(mr[j]))  // <----- check for existence
                        members.add(mr[j]);
        }
}

Any reason why we must check for existence of an resource before adding it to
the member list? Do we expect the getMembers(...) methods to return duplicate
resources?

Reply from John:

With respect to the J2EEFlexProjDeployable, good question, I'm pretty sure the
getMembers() should not return duplicates because throughout the code we always
try and find the existing folder before adding a new folder.  So, those lines
may be candidates for removal.
Comment 1 Jeffrey Liu CLA 2006-08-14 15:19:42 EDT
Adding the performance keyword
Comment 2 Jeffrey Liu CLA 2006-08-14 15:21:34 EDT
Changing priority to P2 because we want to consider this for WTP 1.5.1
Comment 3 John Lanuti CLA 2006-08-15 14:49:27 EDT
These checks were put in unecessarily just to be "safe".  However, they are causing a performance regression in larger workspaces.  The only items we return in the getMembers() list to members() are those which we couldn't find an existing parent for, so there is no need for this check.
Comment 4 John Lanuti CLA 2006-08-15 14:50:01 EDT
Created attachment 47955 [details]
Proposed patch
Comment 5 John Lanuti CLA 2006-08-15 14:51:42 EDT
This patch is ready for review.  Just removed the contains() checks.
Comment 6 Daniel Berg CLA 2006-08-15 17:52:53 EDT
Approve

An alternative if the check is ever needed is to switch to using a Set and not a List.
Comment 7 Jason Sholl CLA 2006-08-16 08:32:34 EDT
Approve.  Don't use a hash; if duplicates are possible stop them from occuring elswhere.
Comment 8 John Lanuti CLA 2006-08-16 09:22:40 EDT
This is released for the 081706 WTP 1.5.1 driver.
Comment 9 Jeffrey Liu CLA 2006-09-21 14:25:46 EDT
verified and close.