Subject | A little nit... |
---|---|
Author | Robert DiFalco |
Post date | 2003-09-19T06:08:17Z |
I'm not quite sure how to get developer's rights on sourceforge,
otherwise I'd just fix it myself. I'm not really familiar with
contributing to open source projects, but I did notice this little
thing. Apparently, FBBlobField is allocating an unnecessary object for
the garbage collector to deal with. Consider this:
Blob getBlob() throws SQLException {
if (blob != null)
return blob;
if (rs.row[numCol]==null)
return BLOB_NULL_VALUE;
Long blobId = new Long(field.decodeLong(rs.row[numCol]));
blob = new FBBlob(c, blobId.longValue());
return blob;
}
Seems this should be re-written as follows to eliminate the unecessary
Long object instantiation:
Blob getBlob() throws SQLException {
if (blob != null)
return blob;
final byte[] bytes = rs.row[ numCol ];
if ( bytes == null )
return BLOB_NULL_VALUE;
blob = new FBBlob( c, field.decodeLong( bytes ) );
return blob;
}
Believe it or not, calling "rs.row[ numCol ]" has some overhead
associated with it (the accessing of "row" with "r" and the accessing of
"numCol" within "row", so this also collapses the array element access
to a single call in the case where rs.row[ numCol ] is not null. But the
main thing is the unneeded creation of the Long object.
Fwiw,
R.
otherwise I'd just fix it myself. I'm not really familiar with
contributing to open source projects, but I did notice this little
thing. Apparently, FBBlobField is allocating an unnecessary object for
the garbage collector to deal with. Consider this:
Blob getBlob() throws SQLException {
if (blob != null)
return blob;
if (rs.row[numCol]==null)
return BLOB_NULL_VALUE;
Long blobId = new Long(field.decodeLong(rs.row[numCol]));
blob = new FBBlob(c, blobId.longValue());
return blob;
}
Seems this should be re-written as follows to eliminate the unecessary
Long object instantiation:
Blob getBlob() throws SQLException {
if (blob != null)
return blob;
final byte[] bytes = rs.row[ numCol ];
if ( bytes == null )
return BLOB_NULL_VALUE;
blob = new FBBlob( c, field.decodeLong( bytes ) );
return blob;
}
Believe it or not, calling "rs.row[ numCol ]" has some overhead
associated with it (the accessing of "row" with "r" and the accessing of
"numCol" within "row", so this also collapses the array element access
to a single call in the case where rs.row[ numCol ] is not null. But the
main thing is the unneeded creation of the Long object.
Fwiw,
R.