Skip to content

Commit

Permalink
Optimize skipRecords. Fixes #100
Browse files Browse the repository at this point in the history
  • Loading branch information
albfernandez committed Jan 3, 2024
1 parent 86060a6 commit 08296e0
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/main/java/com/linuxense/javadbf/DBFReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,26 @@ public void skipRecords(int recordsToSkip) throws IOException {
}
else {
for (int i = 0; i < recordsToSkip; i++) {
nextRecord();
boolean deleted = true;
while(deleted) {
try {
byte theByte = this.dataInputStream.readByte();
if (theByte == -1) {
return;
}
if (theByte == END_OF_DATA && this.header.numberOfRecords == this.internalRecord) {
return;
}
deleted = theByte == '*';
// skip the rest of the record
skip(this.header.recordLength - 1);
this.internalRecord++;
}
catch (EOFException e) {
return;
}
}
this.returnedRecords++;
}
}
}
Expand Down

0 comments on commit 08296e0

Please sign in to comment.