diff --git a/pkg/textparse/parse.go b/pkg/textparse/parse.go index 51d08b932..d04ec2942 100644 --- a/pkg/textparse/parse.go +++ b/pkg/textparse/parse.go @@ -7,7 +7,6 @@ package textparse import ( "errors" "io" - "reflect" "sort" "unsafe" @@ -106,11 +105,5 @@ func (p *Parser) Metric(l *labels.Labels) { } func yoloString(b []byte) string { - sh := (*reflect.SliceHeader)(unsafe.Pointer(&b)) - - h := reflect.StringHeader{ - Data: sh.Data, - Len: sh.Len, - } - return *((*string)(unsafe.Pointer(&h))) + return *((*string)(unsafe.Pointer(&b))) } diff --git a/retrieval/scrape.go b/retrieval/scrape.go index 5391eb3fe..7a2993f43 100644 --- a/retrieval/scrape.go +++ b/retrieval/scrape.go @@ -20,7 +20,6 @@ import ( "fmt" "io" "net/http" - "reflect" "sync" "time" "unsafe" @@ -586,13 +585,7 @@ loop: } func yoloString(b []byte) string { - sh := (*reflect.SliceHeader)(unsafe.Pointer(&b)) - - h := reflect.StringHeader{ - Data: sh.Data, - Len: sh.Len, - } - return *((*string)(unsafe.Pointer(&h))) + return *((*string)(unsafe.Pointer(&b))) } func (sl *scrapeLoop) report(start time.Time, duration time.Duration, scraped, appended int, err error) error {