tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Kerber <dcker...@verizon.net>
Subject Code performance question #2
Date Mon, 07 Aug 2006 15:59:52 GMT
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


Mime
View raw message