Skip to content

Commit

Permalink
[BZip2] Fix incorrect BWT pointer in compression
Browse files Browse the repository at this point in the history
  • Loading branch information
tsolomko committed Dec 15, 2022
1 parent c7f4665 commit b1fe47f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Sources/BZip2/BurrowsWheeler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ enum BurrowsWheeler {
let suffixArray = SuffixArray.make(from: doubleBytes, with: 256)
var bwt = [Int]()
bwt.reserveCapacity(bytes.count)
// Pointer is an index in the transformed array, `bwt`, where the EOF marker would have been if we had used it.
var pointer = 0
for i in 1..<suffixArray.count {
if suffixArray[i] < bytes.count {
Expand All @@ -21,7 +22,7 @@ enum BurrowsWheeler {
bwt.append(bytes.last!)
}
} else if suffixArray[i] == bytes.count {
pointer = (i - 1) / 2
pointer = bwt.count
}
}
return (bwt, pointer)
Expand Down

0 comments on commit b1fe47f

Please sign in to comment.