1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Update to avoid converting entire strings to lower case before

performing compare.  Significant performance gains on larger binaries:
Original (time to sort the symbol array used by the ElfHelper class):
- Sorting 53580 symbols took 6203ms
Modified (traded toLowerCase for compareToIgnoreCase)
- Sorting 53580 symbols took 828ms
This commit is contained in:
Thomas Fletcher 2006-03-23 06:23:09 +00:00
parent 015a69e0dd
commit d0c9930d89
2 changed files with 6 additions and 6 deletions

View file

@ -15,8 +15,8 @@ import java.util.Comparator;
public class SymbolSortCompare implements Comparator { public class SymbolSortCompare implements Comparator {
public int compare( Object o1, Object o2 ) { public int compare( Object o1, Object o2 ) {
String s1 = o1.toString().toLowerCase(); String s1 = o1.toString();
String s2 = o2.toString().toLowerCase(); String s2 = o2.toString();
while( s1.length() > 0 && s1.charAt( 0 ) == '_' ) while( s1.length() > 0 && s1.charAt( 0 ) == '_' )
s1 = s1.substring( 1 ); s1 = s1.substring( 1 );
@ -24,7 +24,7 @@ public class SymbolSortCompare implements Comparator {
while( s2.length() > 0 && s2.charAt( 0 ) == '_' ) while( s2.length() > 0 && s2.charAt( 0 ) == '_' )
s2 = s2.substring( 1 ); s2 = s2.substring( 1 );
return s1.compareTo( s2 ); return s1.compareToIgnoreCase( s2 );
} }
} }

View file

@ -15,8 +15,8 @@ import java.util.Comparator;
public class SymbolSortCompare implements Comparator { public class SymbolSortCompare implements Comparator {
public int compare( Object o1, Object o2 ) { public int compare( Object o1, Object o2 ) {
String s1 = o1.toString().toLowerCase(); String s1 = o1.toString();
String s2 = o2.toString().toLowerCase(); String s2 = o2.toString();
while( s1.length() > 0 && s1.charAt( 0 ) == '_' ) while( s1.length() > 0 && s1.charAt( 0 ) == '_' )
s1 = s1.substring( 1 ); s1 = s1.substring( 1 );
@ -24,7 +24,7 @@ public class SymbolSortCompare implements Comparator {
while( s2.length() > 0 && s2.charAt( 0 ) == '_' ) while( s2.length() > 0 && s2.charAt( 0 ) == '_' )
s2 = s2.substring( 1 ); s2 = s2.substring( 1 );
return s1.compareTo( s2 ); return s1.compareToIgnoreCase( s2 );
} }
} }