summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/modern-go/reflect2/reflect2.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2021-12-12 00:05:15 +0100
committerGitHub <noreply@github.com>2021-12-12 00:05:15 +0100
commit3893a035be347a7687a41d2054dd1b274d3a0504 (patch)
treedfe4a3bf72a0a6356e51bd8fc2e88e9a26e52331 /vendor/github.com/modern-go/reflect2/reflect2.go
parent658bdd9faa835660ae407331732e9d93d8f6443b (diff)
downloadmatterbridge-msglm-3893a035be347a7687a41d2054dd1b274d3a0504.tar.gz
matterbridge-msglm-3893a035be347a7687a41d2054dd1b274d3a0504.tar.bz2
matterbridge-msglm-3893a035be347a7687a41d2054dd1b274d3a0504.zip
Update dependencies/vendor (#1659)
Diffstat (limited to 'vendor/github.com/modern-go/reflect2/reflect2.go')
-rw-r--r--vendor/github.com/modern-go/reflect2/reflect2.go20
1 files changed, 11 insertions, 9 deletions
diff --git a/vendor/github.com/modern-go/reflect2/reflect2.go b/vendor/github.com/modern-go/reflect2/reflect2.go
index 63b49c79..c43c8b9d 100644
--- a/vendor/github.com/modern-go/reflect2/reflect2.go
+++ b/vendor/github.com/modern-go/reflect2/reflect2.go
@@ -1,8 +1,9 @@
package reflect2
import (
- "github.com/modern-go/concurrent"
"reflect"
+ "runtime"
+ "sync"
"unsafe"
)
@@ -130,13 +131,13 @@ var ConfigSafe = Config{UseSafeImplementation: true}.Froze()
type frozenConfig struct {
useSafeImplementation bool
- cache *concurrent.Map
+ cache *sync.Map
}
func (cfg Config) Froze() *frozenConfig {
return &frozenConfig{
useSafeImplementation: cfg.UseSafeImplementation,
- cache: concurrent.NewMap(),
+ cache: new(sync.Map),
}
}
@@ -288,11 +289,12 @@ func NoEscape(p unsafe.Pointer) unsafe.Pointer {
}
func UnsafeCastString(str string) []byte {
+ bytes := make([]byte, 0)
stringHeader := (*reflect.StringHeader)(unsafe.Pointer(&str))
- sliceHeader := &reflect.SliceHeader{
- Data: stringHeader.Data,
- Cap: stringHeader.Len,
- Len: stringHeader.Len,
- }
- return *(*[]byte)(unsafe.Pointer(sliceHeader))
+ sliceHeader := (*reflect.SliceHeader)(unsafe.Pointer(&bytes))
+ sliceHeader.Data = stringHeader.Data
+ sliceHeader.Cap = stringHeader.Len
+ sliceHeader.Len = stringHeader.Len
+ runtime.KeepAlive(str)
+ return bytes
}