Skip to content

Commit

Permalink
tablecodec: optimize DecodeIndexHandle to avoid unnecessary allocation (
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaiamao authored Sep 11, 2024
1 parent 08bebab commit d82f06b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/tablecodec/tablecodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -967,9 +967,13 @@ func DecodeIndexKV(key, value []byte, colsLen int, hdStatus HandleStatus, column

// DecodeIndexHandle uses to decode the handle from index key/value.
func DecodeIndexHandle(key, value []byte, colsLen int) (kv.Handle, error) {
_, b, err := CutIndexKeyNew(key, colsLen)
if err != nil {
return nil, errors.Trace(err)
var err error
b := key[prefixLen+idLen:]
for i := 0; i < colsLen; i++ {
_, b, err = codec.CutOne(b)
if err != nil {
return nil, errors.Trace(err)
}
}
if len(b) > 0 {
return decodeHandleInIndexKey(b)
Expand Down

0 comments on commit d82f06b

Please sign in to comment.