Bug 51246 - Path.computeSegments expensive
Summary: Path.computeSegments expensive
Status: RESOLVED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Platform-Resources-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-05 12:00 EST by Dani Megert CLA
Modified: 2004-02-11 13:33 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2004-02-05 12:00:15 EST
I20040204

I was tracing performance when opening an editor and saw that > 7% is spent in
String.substring which is called by Path.computeSegments(String). The reason why
computeSegments is called can be found in bug 51244 (note: JavaElement.toString
ends up calling Path.computeSegments(String)).
Comment 1 Dani Megert CLA 2004-02-06 08:39:13 EST
Please note that when using builds > 20040206 you might not see this because J
Core already improved the code (see bug 51249).
Comment 2 John Arthorne CLA 2004-02-09 16:16:00 EST
I think the decoration job was just reporting too much progress. Unless you have 
specific optimization recommendations for the computeSegments method, I don't 
see anything else we can do here (it is already fairly well tuned). It is 
inherently expensive because it is creating all of the String objects for each 
segment of the path.
Comment 3 Dani Megert CLA 2004-02-10 04:25:48 EST
Couldn't you setup a reader on the string and then build the array in one pass
without calling substring and in addition inline the call to
computeSegmentCount? I guess this might be faster.
Comment 4 John Arthorne CLA 2004-02-11 13:33:35 EST
The performance of this method is really tied to the number of object creations.
This implementation creates n+1 objects, where n is the number of segments in
the path. This is optimal, considering the internal representation of path as an
array of strings. This representation was carefully chosen to avoid any object
creations while iterating over a path (which is done on every resource tree
lookup), at the expense of slightly more expensive creation time.