Re: Performance of loop

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Gnanavel S <s(dot)gnanavel(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Performance of loop
Date: 2005-04-28 04:22:27
Message-ID: 42706503.7080800@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Gnanavel S wrote:

> 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);
>
> ....
> .....
> }

Have you benchmarked this? I doubt it's really a hotspot given that the
JIT is likely to inline length(). Premature optimization and all that..

-O

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Gnanavel S 2005-04-28 04:38:59 Re: Performance of loop
Previous Message Gnanavel S 2005-04-28 03:56:32 Performance of loop