Skip to content

Commit

Permalink
use slices.Sort to eliminate bounds check
Browse files Browse the repository at this point in the history
Signed-off-by: Weizhen Wang <[email protected]>
  • Loading branch information
hawkingrei committed Jan 23, 2024
1 parent 4591bd8 commit c22f221
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions util/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
"context"
"encoding/hex"
"fmt"
"reflect"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -168,11 +167,7 @@ func String(b []byte) (s string) {
if len(b) == 0 {
return ""
}
pbytes := (*reflect.SliceHeader)(unsafe.Pointer(&b))
pstring := (*reflect.StringHeader)(unsafe.Pointer(&s))
pstring.Data = pbytes.Data
pstring.Len = pbytes.Len
return
return unsafe.String(unsafe.SliceData(b), len(b))
}

// ToUpperASCIIInplace bytes.ToUpper but zero-cost
Expand Down

0 comments on commit c22f221

Please sign in to comment.