Skip to content

Commit 6ea41dc

Browse files
committed
Patch for jdbc2 ResultSet.java. Looks like performance improvement.
Joseph Shraibman
1 parent 1834987 commit 6ea41dc

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ public void close() throws SQLException
134134
{
135135
//release resources held (memory for tuples)
136136
if(rows!=null) {
137-
rows.setSize(0);
138137
rows=null;
139138
}
140139
}
@@ -710,7 +709,8 @@ public int findColumn(String columnName) throws SQLException
710709
{
711710
int i;
712711

713-
for (i = 0 ; i < fields.length; ++i)
712+
final int flen = fields.length;
713+
for (i = 0 ; i < flen; ++i)
714714
if (fields[i].getName().equalsIgnoreCase(columnName))
715715
return (i+1);
716716
throw new PSQLException ("postgresql.res.colname",columnName);
@@ -726,11 +726,13 @@ public boolean absolute(int index) throws SQLException
726726
if (index==0)
727727
throw new SQLException("Cannot move to index of 0");
728728

729+
final int rows_size = rows.size();
730+
729731
//if index<0, count from the end of the result set, but check
730732
//to be sure that it is not beyond the first index
731733
if (index<0)
732-
if (index>=-rows.size())
733-
internalIndex=rows.size()+index;
734+
if (index > -rows_size)
735+
internalIndex = rows_size+index;
734736
else {
735737
beforeFirst();
736738
return false;
@@ -739,7 +741,7 @@ public boolean absolute(int index) throws SQLException
739741
//must be the case that index>0,
740742
//find the correct place, assuming that
741743
//the index is not too large
742-
if (index<=rows.size())
744+
if (index <= rows_size)
743745
internalIndex = index-1;
744746
else {
745747
afterLast();
@@ -753,8 +755,9 @@ public boolean absolute(int index) throws SQLException
753755

754756
public void afterLast() throws SQLException
755757
{
756-
if (rows.size() > 0)
757-
current_row = rows.size();
758+
final int rows_size = rows.size();
759+
if (rows_size > 0)
760+
current_row = rows_size;
758761
}
759762

760763
public void beforeFirst() throws SQLException
@@ -967,7 +970,8 @@ public void insertRow() throws SQLException
967970

968971
public boolean isAfterLast() throws SQLException
969972
{
970-
return (current_row >= rows.size() && rows.size() > 0);
973+
final int rows_size = rows.size();
974+
return (current_row >= rows_size && rows_size > 0);
971975
}
972976

973977
public boolean isBeforeFirst() throws SQLException
@@ -982,16 +986,18 @@ public boolean isFirst() throws SQLException
982986

983987
public boolean isLast() throws SQLException
984988
{
985-
return (current_row == rows.size() -1 && rows.size() > 0);
989+
final int rows_size = rows.size();
990+
return (current_row == rows_size -1 && rows_size > 0);
986991
}
987992

988993
public boolean last() throws SQLException
989994
{
990-
if (rows.size() <= 0)
991-
return false;
992-
current_row = rows.size() - 1;
993-
this_row = (byte [][])rows.elementAt(current_row);
994-
return true;
995+
final int rows_size = rows.size();
996+
if (rows_size <= 0)
997+
return false;
998+
current_row = rows_size - 1;
999+
this_row = (byte [][])rows.elementAt(current_row);
1000+
return true;
9951001
}
9961002

9971003
public void moveToCurrentRow() throws SQLException
@@ -1480,4 +1486,3 @@ public static Timestamp toTimestamp(String s, ResultSet resultSet) throws SQLExc
14801486
}
14811487
}
14821488
}
1483-

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy