mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-27 08:39:28 +08:00
Performance tweaks to StringBuffer suggested by hhaag@gmx.de
Modified Files: jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java jdbc/org/postgresql/util/PGbytea.java
This commit is contained in:
parent
ab0f98518c
commit
875364e5ff
@ -13,7 +13,7 @@ import org.postgresql.largeobject.*;
|
||||
import org.postgresql.util.PGbytea;
|
||||
import org.postgresql.util.PSQLException;
|
||||
|
||||
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.3 2002/08/14 20:35:39 barry Exp $
|
||||
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.4 2002/08/16 17:51:38 barry Exp $
|
||||
* This class defines methods of the jdbc1 specification. This class is
|
||||
* extended by org.postgresql.jdbc2.AbstractJdbc2ResultSet which adds the jdbc2
|
||||
* methods. The real ResultSet class (for jdbc1) is org.postgresql.jdbc1.Jdbc1ResultSet
|
||||
@ -851,9 +851,10 @@ public abstract class AbstractJdbc1ResultSet
|
||||
|
||||
// If first time, create the buffer, otherwise clear it.
|
||||
if (rs.sbuf == null)
|
||||
rs.sbuf = new StringBuffer();
|
||||
else
|
||||
rs.sbuf = new StringBuffer(32);
|
||||
else {
|
||||
rs.sbuf.setLength(0);
|
||||
}
|
||||
|
||||
// Copy s into sbuf for parsing.
|
||||
rs.sbuf.append(s);
|
||||
|
@ -8,7 +8,7 @@ import java.util.Vector;
|
||||
import org.postgresql.largeobject.*;
|
||||
import org.postgresql.util.*;
|
||||
|
||||
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.3 2002/07/25 22:45:27 barry Exp $
|
||||
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.4 2002/08/16 17:51:38 barry Exp $
|
||||
* This class defines methods of the jdbc1 specification. This class is
|
||||
* extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
|
||||
* methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
|
||||
@ -40,7 +40,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
|
||||
private static final short ESC_TIMEDATE = 3;
|
||||
|
||||
// Some performance caches
|
||||
private StringBuffer sbuf = new StringBuffer();
|
||||
private StringBuffer sbuf = new StringBuffer(32);
|
||||
|
||||
//Used by the preparedstatement style methods
|
||||
protected String sql;
|
||||
@ -498,7 +498,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
|
||||
{
|
||||
// Since escape codes can only appear in SQL CODE, we keep track
|
||||
// of if we enter a string or not.
|
||||
StringBuffer newsql = new StringBuffer();
|
||||
StringBuffer newsql = new StringBuffer(sql.length());
|
||||
short state = IN_SQLCODE;
|
||||
|
||||
int i = -1;
|
||||
@ -736,6 +736,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
|
||||
synchronized (sbuf)
|
||||
{
|
||||
sbuf.setLength(0);
|
||||
sbuf.ensureCapacity(x.length());
|
||||
int i;
|
||||
|
||||
sbuf.append('\'');
|
||||
@ -852,6 +853,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
|
||||
synchronized (sbuf)
|
||||
{
|
||||
sbuf.setLength(0);
|
||||
sbuf.ensureCapacity(32);
|
||||
sbuf.append("'");
|
||||
//format the timestamp
|
||||
//we do our own formating so that we can get a format
|
||||
|
@ -5,7 +5,7 @@ import java.sql.*;
|
||||
/*
|
||||
* Converts to and from the postgresql bytea datatype used by the backend.
|
||||
*
|
||||
* $Id: PGbytea.java,v 1.4 2002/01/05 22:26:23 barry Exp $
|
||||
* $Id: PGbytea.java,v 1.5 2002/08/16 17:51:38 barry Exp $
|
||||
*/
|
||||
|
||||
public class PGbytea
|
||||
@ -62,7 +62,7 @@ public class PGbytea
|
||||
{
|
||||
if (p_buf == null)
|
||||
return null;
|
||||
StringBuffer l_strbuf = new StringBuffer();
|
||||
StringBuffer l_strbuf = new StringBuffer(p_buf.length);
|
||||
for (int i = 0; i < p_buf.length; i++)
|
||||
{
|
||||
int l_int = (int)p_buf[i];
|
||||
|
Loading…
Reference in New Issue
Block a user