@@ -134,7 +134,6 @@ public void close() throws SQLException
134
134
{
135
135
//release resources held (memory for tuples)
136
136
if (rows !=null ) {
137
- rows .setSize (0 );
138
137
rows =null ;
139
138
}
140
139
}
@@ -710,7 +709,8 @@ public int findColumn(String columnName) throws SQLException
710
709
{
711
710
int i ;
712
711
713
- for (i = 0 ; i < fields .length ; ++i )
712
+ final int flen = fields .length ;
713
+ for (i = 0 ; i < flen ; ++i )
714
714
if (fields [i ].getName ().equalsIgnoreCase (columnName ))
715
715
return (i +1 );
716
716
throw new PSQLException ("postgresql.res.colname" ,columnName );
@@ -726,11 +726,13 @@ public boolean absolute(int index) throws SQLException
726
726
if (index ==0 )
727
727
throw new SQLException ("Cannot move to index of 0" );
728
728
729
+ final int rows_size = rows .size ();
730
+
729
731
//if index<0, count from the end of the result set, but check
730
732
//to be sure that it is not beyond the first index
731
733
if (index <0 )
732
- if (index >=- rows . size () )
733
- internalIndex = rows . size () +index ;
734
+ if (index > - rows_size )
735
+ internalIndex = rows_size +index ;
734
736
else {
735
737
beforeFirst ();
736
738
return false ;
@@ -739,7 +741,7 @@ public boolean absolute(int index) throws SQLException
739
741
//must be the case that index>0,
740
742
//find the correct place, assuming that
741
743
//the index is not too large
742
- if (index <= rows . size () )
744
+ if (index <= rows_size )
743
745
internalIndex = index -1 ;
744
746
else {
745
747
afterLast ();
@@ -753,8 +755,9 @@ public boolean absolute(int index) throws SQLException
753
755
754
756
public void afterLast () throws SQLException
755
757
{
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 ;
758
761
}
759
762
760
763
public void beforeFirst () throws SQLException
@@ -967,7 +970,8 @@ public void insertRow() throws SQLException
967
970
968
971
public boolean isAfterLast () throws SQLException
969
972
{
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 );
971
975
}
972
976
973
977
public boolean isBeforeFirst () throws SQLException
@@ -982,16 +986,18 @@ public boolean isFirst() throws SQLException
982
986
983
987
public boolean isLast () throws SQLException
984
988
{
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 );
986
991
}
987
992
988
993
public boolean last () throws SQLException
989
994
{
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 ;
995
1001
}
996
1002
997
1003
public void moveToCurrentRow () throws SQLException
@@ -1480,4 +1486,3 @@ public static Timestamp toTimestamp(String s, ResultSet resultSet) throws SQLExc
1480
1486
}
1481
1487
}
1482
1488
}
1483
-
0 commit comments