Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 67750 invoked from network); 7 Aug 2006 16:05:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 7 Aug 2006 16:05:43 -0000 Received: (qmail 28621 invoked by uid 500); 7 Aug 2006 16:05:30 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 28599 invoked by uid 500); 7 Aug 2006 16:05:30 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 28588 invoked by uid 99); 7 Aug 2006 16:05:30 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Aug 2006 09:05:30 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of rosenberg.leon@googlemail.com designates 64.233.182.188 as permitted sender) Received: from [64.233.182.188] (HELO nf-out-0910.google.com) (64.233.182.188) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Aug 2006 09:05:29 -0700 Received: by nf-out-0910.google.com with SMTP id a4so384976nfc for ; Mon, 07 Aug 2006 09:05:08 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=googlemail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=kg7mHlaBlQWCyBqEYIy6VOKO9WQyGeSfuWdIikbV5FgcN2loerI8d7gBxDYA0eEOtE6T4TJxQLcSqXVU5QcLLb6rTtjwbFv5jYNGy6uc4dvHmk0kfYDI8oRMJqIFBpF70vXpoDLFQT/S+el5af+6XXX6C48kvMMaHLbdYuio/Oo= Received: by 10.78.120.6 with SMTP id s6mr2448663huc; Mon, 07 Aug 2006 09:05:08 -0700 (PDT) Received: by 10.78.161.5 with HTTP; Mon, 7 Aug 2006 09:05:08 -0700 (PDT) Message-ID: <327858f40608070905y661e6bfdgb0fc78fff61e15fd@mail.gmail.com> Date: Mon, 7 Aug 2006 18:05:08 +0200 From: "Leon Rosenberg" To: "Tomcat Users List" Subject: Re: Code performance question #2 In-Reply-To: <44D76378.1030808@verizon.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <44D76378.1030808@verizon.net> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 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