mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-13 15:46:49 +03:00
optimized b2s function (#1483)
This commit is contained in:
committed by
GitHub
parent
2e81dca7b2
commit
b0fe6f00d2
+1
-5
@@ -8,9 +8,5 @@ import "unsafe"
|
||||
// b2s converts byte slice to a string without memory allocation.
|
||||
// See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .
|
||||
func b2s(b []byte) string {
|
||||
if len(b) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
return unsafe.String(&b[0], len(b))
|
||||
return unsafe.String(unsafe.SliceData(b), len(b))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user