mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
*: Simplify []byte to string unsafe conversion
This commit is contained in:
parent
30727b1e71
commit
d9fb57cde4
|
@ -7,7 +7,6 @@ package textparse
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"reflect"
|
|
||||||
"sort"
|
"sort"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
@ -106,11 +105,5 @@ func (p *Parser) Metric(l *labels.Labels) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func yoloString(b []byte) string {
|
func yoloString(b []byte) string {
|
||||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
|
return *((*string)(unsafe.Pointer(&b)))
|
||||||
|
|
||||||
h := reflect.StringHeader{
|
|
||||||
Data: sh.Data,
|
|
||||||
Len: sh.Len,
|
|
||||||
}
|
|
||||||
return *((*string)(unsafe.Pointer(&h)))
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"reflect"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
@ -586,13 +585,7 @@ loop:
|
||||||
}
|
}
|
||||||
|
|
||||||
func yoloString(b []byte) string {
|
func yoloString(b []byte) string {
|
||||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
|
return *((*string)(unsafe.Pointer(&b)))
|
||||||
|
|
||||||
h := reflect.StringHeader{
|
|
||||||
Data: sh.Data,
|
|
||||||
Len: sh.Len,
|
|
||||||
}
|
|
||||||
return *((*string)(unsafe.Pointer(&h)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sl *scrapeLoop) report(start time.Time, duration time.Duration, scraped, appended int, err error) error {
|
func (sl *scrapeLoop) report(start time.Time, duration time.Duration, scraped, appended int, err error) error {
|
||||||
|
|
Loading…
Reference in a new issue