thats ugly, why don't you tokenize it into string pairs, store the pairs and works with them? leon
On 8/7/06, David Kerber <[EMAIL PROTECTED]> wrote:
This code is part of a servlet running in TC 5.5.12, jre ver 1.5.0.6. I use this code to break out individual data fields from a line which is structured as "a=11111&b=22222&c=333333333&d=44444&e=5". It is executed for over 2 million data lines per day, so this routine is executed over 10 million times per day. All the fields are short ( < 10 chars) except the 5th one, which can be up to about 40 characters. Is there a more cpu-efficient way of doing this, or is this about as good as it gets? private static String getField ( String fieldName, String dataString ) { Integer ii, kk; ii = dataString.indexOf( fieldName + "=" ); if (ii == -1 ) return null; kk = dataString.indexOf( "&", ii ); if ( kk.equals( -1 )) { kk = dataString.length(); } return ( dataString.substring( ii + 2, kk )); } TIA! Dave --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]