diff options
author | orangesobeautiful <74104118+orangesobeautiful@users.noreply.github.com> | 2023-02-08 15:24:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-08 08:24:24 +0100 |
commit | b0fe6f00d20b7a7e16589757d660be45520097b3 (patch) | |
tree | e58e1e19909c5ffda9f23a34d7d0d5563fe411b2 /b2s_new.go | |
parent | update compress modulule, drop 1.16 (#1482) (diff) | |
download | fasthttp-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.go | 6 |
1 files changed, 1 insertions, 5 deletions
@@ -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)) } |