Skip to content

Commit

Permalink
change the reflect package to an unsafe package (#7143)
Browse files Browse the repository at this point in the history
- as 'reflect.String.Header' is deprecated, it is replaced with an unsafe package.

Signed-off-by: Youngjun <[email protected]>
  • Loading branch information
yj-yoo authored Apr 11, 2024
1 parent 8227108 commit 652e8cc
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions pkg/store/cache/inmemory.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package storecache

import (
"context"
"reflect"
"sync"
"unsafe"

Expand Down Expand Up @@ -277,12 +276,7 @@ func (c *InMemoryIndexCache) reset() {
}

func copyString(s string) string {
var b []byte
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
h.Data = (*reflect.StringHeader)(unsafe.Pointer(&s)).Data
h.Len = len(s)
h.Cap = len(s)
return string(b)
return string(unsafe.Slice(unsafe.StringData(s), len(s)))
}

// copyToKey is required as underlying strings might be mmaped.
Expand Down

0 comments on commit 652e8cc

Please sign in to comment.