diff --git a/compress_fragment.go b/compress_fragment.go index 435898e..2fc2df1 100644 --- a/compress_fragment.go +++ b/compress_fragment.go @@ -33,14 +33,8 @@ func hashBytesAtOffset5(v uint64, offset int, shift uint) uint32 { } func isMatch5(p1 []byte, p2 []byte) bool { - var i int - for i = 0; i < 5; i++ { - if p1[i] != p2[i] { - return false - } - } - - return true + return binary.LittleEndian.Uint32(p1) == binary.LittleEndian.Uint32(p2) && + p1[4] == p2[4] } /* Builds a literal prefix code into "depths" and "bits" based on the statistics diff --git a/compress_fragment_two_pass.go b/compress_fragment_two_pass.go index ffeb321..172dc7f 100644 --- a/compress_fragment_two_pass.go +++ b/compress_fragment_two_pass.go @@ -30,14 +30,13 @@ func hashBytesAtOffset(v uint64, offset uint, shift uint, length uint) uint32 { } func isMatch1(p1 []byte, p2 []byte, length uint) bool { - var i uint - for i = 0; i < length && i < 6; i++ { - if p1[i] != p2[i] { - return false - } + if binary.LittleEndian.Uint32(p1) != binary.LittleEndian.Uint32(p2) { + return false } - - return true + if length == 4 { + return true + } + return p1[4] == p2[4] && p1[5] == p2[5] } /* Builds a command and distance prefix code (each 64 symbols) into "depth" and