Skip to content

Commit

Permalink
Speed optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
flanglet committed Feb 25, 2024
1 parent be45475 commit 06bd7e1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions v2/transform/RLT.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package transform
// 7172 <= runLen < 65535+7172 -> 3 bytes

import (
"encoding/binary"
"errors"
"fmt"
"strings"
Expand Down Expand Up @@ -160,10 +161,16 @@ func (this *RLT) Forward(src, dst []byte) (uint, uint, error) {
// Main loop
for {
if prev == src[srcIdx] {
srcIdx++
run++
v := uint32(0x01010101) * uint32(prev)

if v == binary.LittleEndian.Uint32(src[srcIdx:]) {
srcIdx += 4
run += 4

if prev == src[srcIdx] {
if (run < _RLT_MAX_RUN4) && (srcIdx < srcEnd4) {
continue
}
} else if prev == src[srcIdx] {
srcIdx++
run++

Expand Down

0 comments on commit 06bd7e1

Please sign in to comment.