This is an automated email from the ASF dual-hosted git repository. jsorel pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push: new 54a78ecf62 fix(Shapefile): replace skipBytes by seek, more efficient and avoids a loop 54a78ecf62 is described below commit 54a78ecf623a37156cd546337a592cee0ccd958a Author: jsorel <johann.so...@geomatys.com> AuthorDate: Fri Nov 24 11:21:24 2023 +0100 fix(Shapefile): replace skipBytes by seek, more efficient and avoids a loop --- .../main/org/apache/sis/storage/shapefile/dbf/DBFField.java | 2 +- .../main/org/apache/sis/storage/shapefile/dbf/DBFHeader.java | 2 +- .../main/org/apache/sis/storage/shapefile/dbf/DBFReader.java | 4 ++-- .../main/org/apache/sis/storage/shapefile/shp/ShapeHeader.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFField.java b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFField.java index 1465e84060..85976ea76a 100644 --- a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFField.java +++ b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFField.java @@ -139,7 +139,7 @@ public final class DBFField { final int fieldAddress = channel.readInt(); final int fieldLength = channel.readUnsignedByte(); final int fieldDecimals = channel.readUnsignedByte(); - channel.skipBytes(14); + channel.seek(channel.getStreamPosition() + 14); return new DBFField(fieldName, fieldType, fieldAddress, fieldLength, fieldDecimals, charset); } diff --git a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFHeader.java b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFHeader.java index a20c4ddfcf..dde089f6d6 100644 --- a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFHeader.java +++ b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFHeader.java @@ -76,7 +76,7 @@ public final class DBFHeader { nbRecord = channel.readInt(); headerSize = channel.readUnsignedShort(); recordSize = channel.readUnsignedShort(); - channel.skipBytes(20); + channel.seek(channel.getStreamPosition() + 20); fields = new DBFField[(headerSize - FIELD_SIZE - 1) / FIELD_SIZE]; for (int i = 0; i < fields.length; i++) { diff --git a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFReader.java b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFReader.java index a2dbf4a764..848743b5ac 100644 --- a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFReader.java +++ b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFReader.java @@ -73,7 +73,7 @@ public final class DBFReader implements AutoCloseable { final int marker = channel.readUnsignedByte(); if (marker == TAG_DELETED) { - channel.skipBytes(header.recordSize); + channel.seek(channel.getStreamPosition() + header.recordSize); return DBFRecord.DELETED; } else if (marker == TAG_EOF) { return null; @@ -97,7 +97,7 @@ public final class DBFReader implements AutoCloseable { record.fields[k++] = header.fields[i].readValue(channel); } else { //skip this field - channel.skipBytes(header.fields[i].fieldLength); + channel.seek(channel.getStreamPosition() + header.fields[i].fieldLength); } } } diff --git a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/shp/ShapeHeader.java b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/shp/ShapeHeader.java index 5c177f5238..dd89bdd7c8 100644 --- a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/shp/ShapeHeader.java +++ b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/shp/ShapeHeader.java @@ -77,7 +77,7 @@ public final class ShapeHeader { throw new IOException("Incorrect file signature"); } //skip unused datas - channel.skipBytes(5*4); + channel.seek(channel.getStreamPosition() + 5*4); fileLength = channel.readInt() * 2; //in 16bits words channel.buffer.order(ByteOrder.LITTLE_ENDIAN);