Performance of loop

From: Gnanavel S <s(dot)gnanavel(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Performance of loop
Date: 2005-04-28 03:56:32
Message-ID: eec3b03c050427205669495af0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,
First of all, I would like to thank the postgresql team for providing this
wonderful product.

Coming to the point, in postgresql jdbc driver coding, I saw many
inefficient "for" loops. For eg in V2Query.class file
While parsing the parameterized query, there is a "for" loop as this

for (int i = 0; i < query.length(); ++i)
{
char c = 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 = 0,c=query.length(); i < c; ++i)
{
char c = query.charAt(i);

....
.....
}

with regards,
S.Gnanavel
Software Engineer
Satyam Computer Services Ltd

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2005-04-28 04:22:27 Re: Performance of loop
Previous Message Gnanavel S 2005-04-28 03:51:26 Performance of loop