Bug 145271 - "if" check in PDOMSearchRe sult.computeContainedMatches() should be pulled into the outer loop.
Summary: "if" check in PDOMSearchRe sult.computeContainedMatches() should be pulled in...
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.1   Edit
Assignee: Doug Schaefer CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2006-06-05 00:38 EDT by Neeraj Bhope CLA
Modified: 2008-06-19 13:56 EDT (History)
1 user (show)

See Also:


Attachments
The needful. (1.26 KB, patch)
2006-06-05 00:47 EDT, Neeraj Bhope CLA
bjorn.freeman-benson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Neeraj Bhope CLA 2006-06-05 00:38:15 EDT
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()]); 
        } 
-------------
Comment 1 Neeraj Bhope CLA 2006-06-05 00:47:49 EDT
Created attachment 43430 [details]
The needful.
Comment 2 Doug Schaefer CLA 2006-07-11 16:49:11 EDT
I'll be mucking in here so I'll take a look.
Comment 3 Doug Schaefer CLA 2006-08-02 10:42:06 EDT
I have applied the patch. Thanks!