X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B484F54630 for ; Thu, 28 Apr 2005 00:56:34 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 68410-07 for ; Thu, 28 Apr 2005 03:56:33 +0000 (GMT) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.203]) by svr1.postgresql.org (Postfix) with ESMTP id 01CFC54339 for ; Thu, 28 Apr 2005 00:56:32 -0300 (ADT) Received: by zproxy.gmail.com with SMTP id 34so728464nzf for ; Wed, 27 Apr 2005 20:56:32 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type; b=crJhO4ZJNxsE7Bzkmi8sAJL8XT3zYDz2RjWhd3HFww7u0S+WDwZ1aeYsz+FnJt4zNqIz65xb40oS1ep7QlITdC/j5oi5J/swpIAHSb0OcSyL4DkL4XAvJoeAuqnSbyW2y3tO0GF4qkN422Iiosa6x0w2Qn5c7tsbZgaP77RyoVk= Received: by 10.36.61.11 with SMTP id j11mr78956nza; Wed, 27 Apr 2005 20:56:32 -0700 (PDT) Received: by 10.36.60.12 with HTTP; Wed, 27 Apr 2005 20:56:32 -0700 (PDT) Message-ID: Date: Thu, 28 Apr 2005 09:26:32 +0530 From: Gnanavel S Reply-To: Gnanavel S To: pgsql-jdbc@postgresql.org Subject: Performance of loop Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_8481_22170446.1114660592012" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.809 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, HTML_20_30, HTML_MESSAGE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200504/186 X-Sequence-Number: 12793 ------=_Part_8481_22170446.1114660592012 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, First of all, I would like to thank the postgresql team for providing this= =20 wonderful product.=20 Coming to the point, in postgresql jdbc driver coding, I saw many=20 inefficient "for" loops. For eg in V2Query.class file While parsing the parameterized query, there is a "for" loop as this=20 for (int i =3D 0; i < query.length(); ++i) { char c =3D query.charAt(i); .... ..... } In the above coding, say if the length of the query is 1000 characters then= =20 the query.length() is evaluated 1000 times there by reducing the=20 performance. I think the loop can be rewritten as for (int i =3D 0,c=3Dquery.length(); i < c; ++i) { char c =3D query.charAt(i); .... ..... } with regards, S.Gnanavel Software Engineer Satyam Computer Services Ltd ------=_Part_8481_22170446.1114660592012 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi,
  First of all, I would like to thank the postgresql team for providin= g this wonderful product.

  Coming to the point, in postgresql jdbc driver coding, I saw many in= efficient "for" loops. For eg in V2Query.class file
 While parsing the parameterized query, there is a "for" loo= p as this
 
for (int i =3D 0; i < query.length(); ++i)
{
char c =3D query.charAt(i);

....
.....
}

In the above coding, say if the length of the query is 1000 characters then the query.length() is evaluated 1000 times there by reducing the performance.
 I think the loop can be rewritten as

for (int i =3D 0,c=3Dquery.length(); i < c; ++i)
{
char c =3D query.charAt(i);

....
.....
}

with regards,
S.Gnanavel
Software Engineer
Satyam Computer Services Ltd
------=_Part_8481_22170446.1114660592012--