aboutsummaryrefslogtreecommitdiff
path: root/b2s_new.go
diff options
context:
space:
mode:
authorGravatar orangesobeautiful <74104118+orangesobeautiful@users.noreply.github.com> 2023-02-08 15:24:24 +0800
committerGravatar GitHub <noreply@github.com> 2023-02-08 08:24:24 +0100
commitb0fe6f00d20b7a7e16589757d660be45520097b3 (patch)
treee58e1e19909c5ffda9f23a34d7d0d5563fe411b2 /b2s_new.go
parentupdate compress modulule, drop 1.16 (#1482) (diff)
downloadfasthttp-b0fe6f00d20b7a7e16589757d660be45520097b3.tar.gz
fasthttp-b0fe6f00d20b7a7e16589757d660be45520097b3.tar.bz2
fasthttp-b0fe6f00d20b7a7e16589757d660be45520097b3.zip
optimized b2s function (#1483)
Diffstat (limited to 'b2s_new.go')
-rw-r--r--b2s_new.go6
1 files changed, 1 insertions, 5 deletions
diff --git a/b2s_new.go b/b2s_new.go
index 2cbf5e3..2f7d6f7 100644
--- a/b2s_new.go
+++ b/b2s_new.go
@@ -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))
}