mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-24 11:20:18 +01:00
5f33fc8e46
This is manual merge of the https://github.com/VictoriaMetrics/VictoriaMetrics/pull/152 Thanks to nustinov@gmail.com for the initial pull request.
31 lines
524 B
Go
31 lines
524 B
Go
package fastjson
|
|
|
|
import (
|
|
"reflect"
|
|
"unsafe"
|
|
)
|
|
|
|
func b2s(b []byte) string {
|
|
return *(*string)(unsafe.Pointer(&b))
|
|
}
|
|
|
|
func s2b(s string) []byte {
|
|
strh := (*reflect.StringHeader)(unsafe.Pointer(&s))
|
|
var sh reflect.SliceHeader
|
|
sh.Data = strh.Data
|
|
sh.Len = strh.Len
|
|
sh.Cap = strh.Len
|
|
return *(*[]byte)(unsafe.Pointer(&sh))
|
|
}
|
|
|
|
const maxStartEndStringLen = 80
|
|
|
|
func startEndString(s string) string {
|
|
if len(s) <= maxStartEndStringLen {
|
|
return s
|
|
}
|
|
start := s[:40]
|
|
end := s[len(s)-40:]
|
|
return start + "..." + end
|
|
}
|