tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leon Rosenberg" <rosenberg.l...@googlemail.com>
Subject Re: Code performance question #2
Date Mon, 07 Aug 2006 16:05:08 GMT
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 <dckerber@verizon.net> 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: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message