From: | Frederik Wiers <frederik(dot)wiers(at)gmail(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | StringBuffer vs. StringBuilder |
Date: | 2014-01-20 00:37:51 |
Message-ID: | CAP9CZQLD7JNWfGaUexXFEr_pi-Uiwz4srfBS=YkskU9CLGMw7g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Hello,
suggestion for a small performance improvement: replace StringBuffer with
StringBuilder when the StringBuffer is used as a local variable in a method.
I just browsed the git-repo (
https://github.com/pgjdbc/pgjdbc/tree/master/org/postgresql) looking for
prepared statement caching (which I could not find, but that is for another
day) and saw a lot of places where StringBuffer can be replaced by
StringBuilder.
The little performance test shown at
http://stackoverflow.com/a/2771852/3080094
indicates that if StringBuffer is used a lot, replacing it with
StringBuilder can make a difference. And I can not think of a reason to use
a StringBuffer if it is just used locally in a method to build a String.
Frederik
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Nelson | 2014-01-20 14:07:53 | Re: StringBuffer vs. StringBuilder |
Previous Message | Andreas Joseph Krogh | 2014-01-19 14:07:56 | Re: Will Connection.createBlob be implemented any time soon? |