Open karelbilek opened 2 hours ago
I see that you actually use
func UnsafeString(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
}
which should be roughly the same. So.... I guess it's the same
You are welcome to send a PR as a cosmetic fix. We are at minimum Go 1.20, so it should be fine.
I will first try to bench first if it makes anything faster.
99% sure it will be the same. I am willing to be surprised, though :)
yeah it seems exactly the same with regards to speed, even when I inline; not sure why my earlier experiments were so different, probably noise. OK I will make a PR but it will be really just a cosmetic change
since go1.20, there is unsafe.String/unsafe.StringData
Looks like this
I have found these functions really fast. (and it's also much faster to directly inline their usage rather than put them in a wrapper function, btw.)
I think those might be useful here. I will try to have a look where would I add them :D