UniStringChange
For a 377,715 character UniString?, this code takes over 3 minutes to run on my desktop:
String mark = uString.get[[MarkCharacter]]( [[UniTokens]].FM ); String linesep = System.getProperty( "line.separator" ); uString.change( mark, linesep );
Doing the same thing on the database server takes less than a second:
OPEN 'HOLD' TO F.HOLD ELSE STOP K.HOLD = 'FFAREP.01.WSMOAK.022004' READ R.HOLD FROM F.HOLD, K.HOLD THEN SWAP @FM WITH CHAR(010):CHAR(013) IN R.HOLD END
Admittedly my machine is less powerful than the 4-processor database server, but I still think 3 minutes is excessive. What is UniString? doing in there?!
I considered moving the string manipulation up to the database server and having a subroutine do the read and swap before returning the text, but thought I'd give Java a shot at it first:
String temp = uString.toString(); String mark = uString.get[[MarkCharacter]]( [[UniTokens]].FM ); String linesep = System.getProperty( "line.separator" ); String temp2 = temp.replaceAll( mark, linesep );
That runs in 1/3 of a second. Good news, I don't have to write a subroutine!
String.replaceAll arrived with JDK 1.4, so it's understandable that UniObjects for Java doesn't use it. However, until UniString.change() is improved, I can't recommend using it for large Strings.