StringBuffer vs. StringBuilder - Mailing list pgsql-jdbc

From Frederik Wiers
Subject StringBuffer vs. StringBuilder
Date
Msg-id CAP9CZQLD7JNWfGaUexXFEr_pi-Uiwz4srfBS=YkskU9CLGMw7g@mail.gmail.com
Whole thread Raw
Responses Re: StringBuffer vs. StringBuilder  (Stephen Nelson <stephen@eccostudio.com>)
Re: StringBuffer vs. StringBuilder  (Dave Cramer <pg@fastcrypt.com>)
List 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


pgsql-jdbc by date:

Previous
From: Andreas Joseph Krogh
Date:
Subject: Re: Will Connection.createBlob be implemented any time soon?
Next
From: Stephen Nelson
Date:
Subject: Re: StringBuffer vs. StringBuilder