Community
Participate
Working Groups
This fix should give a minor perf improvement in cases where a search results in large number of matches. Pasting mail sent to CDT dev and Doug's reply to it. ----------- Maybe. This code was written before I made the elements include the filename. Feel free to raise a bug. Doug Schaefer, QNX Software Systems Eclipse CDT Project Lead, Tools PMC member http://cdtdoug.blogspot.com From: cdt-dev-bounces@eclipse.org [mailto:cdt-dev-bounces@eclipse.org] On Behalf Of Neeraj U Bhope Sent: Friday, June 02, 2006 5:56 AM To: cdt-dev@eclipse.org Subject: [cdt-dev] Pulling an if check out of the loop in PDOMSearchResult.computeContainedMatches() In the following piece of code, could the "if (filename.equals(mfilename))" check be moved out into the outer loop using ((PDOMSearchElement) elements[i]).getFileName() to populate mfileName? The inner loop would then be entered only for the required file? If not why not? private Match[] computeContainedMatches(AbstractTextSearchResult result, String filename) throws CoreException { List list = new ArrayList(); Object[] elements = result.getElements(); for (int i = 0; i < elements.length; ++i) { Match[] matches = result.getMatches(elements[i]); for (int j = 0; j < matches.length; ++j) { if (matches[j] instanceof PDOMSearchMatch) { String mfilename = ((PDOMSearchMatch)matches[j]).getFileName(); if (filename.equals(mfilename)) list.add(matches[j]); } } } return (Match[])list.toArray(new Match[list.size()]); } -------------
Created attachment 43430 [details] The needful.
I'll be mucking in here so I'll take a look.
I have applied the patch. Thanks!