Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 340317 - TextUtils.getShortString() is slow for longer texts
Summary: TextUtils.getShortString() is slow for longer texts
Status: CLOSED DUPLICATE of bug 440812
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Nebula (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Thomas Schindl CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-17 10:12 EDT by Markus Barchfeld CLA
Modified: 2021-07-05 11:40 EDT (History)
2 users (show)

See Also:


Attachments
Patch for Text Util (9.47 KB, patch)
2011-03-17 10:12 EDT, Markus Barchfeld CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Barchfeld CLA 2011-03-17 10:12:02 EDT
Build Identifier: 3.5.2

TextUtils.getShortString() is used from the DefaultCellRenderer to abbreviate texts if the grid is not word wrapping. For particular strings  with a length of about 2000 characters this method can consume up to 600ms on my Core duo 2.5 GHZ.

The algorithm splits the string and then decreases it by one until it fits into the width of the column. For every turn it calls GC.textExtent twice. Assuming that the text width is an ordered function over the character size the algorithm could use a binary search and thereby reduce the number of calls from n to log n. 

Attached is a patch with the modified algorithm and test cases for checking the compatibility with the existing implementation. It reduces the time to about 15ms for the example (which is also part of the test case).


Reproducible: Always
Comment 1 Markus Barchfeld CLA 2011-03-17 10:12:46 EDT
Created attachment 191419 [details]
Patch for Text Util
Comment 2 Mirko Paturzo CLA 2016-01-22 02:44:11 EST

*** This bug has been marked as a duplicate of bug 440812 ***