Skip to content

Commit

Permalink
Merge pull request #65 from gofiber/update_unsafe_functions
Browse files Browse the repository at this point in the history
Update unsafe functions
  • Loading branch information
ReneWerner87 authored Feb 10, 2024
2 parents 8e32cd4 + 119dde2 commit 14ab51b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
"unsafe"
)

const MaxStringLen = 0x7fff0000 // Maximum string length for UnsafeBytes. (decimal: 2147418112)

// #nosec G103
// UnsafeString returns a string pointer without allocation
func UnsafeString(b []byte) string {
// the new way is slower `return unsafe.String(unsafe.SliceData(b), len(b))`
// unsafe.Pointer variant: 0.5410 ns/op vs unsafe.String variant: 0.3538 ns/op
return *(*string)(unsafe.Pointer(&b))
}

Expand Down

0 comments on commit 14ab51b

Please sign in to comment.