mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-14 15:56:44 +03:00
d356cacd84
In theory this can optimize some code paths where a string first needs to be converted to a []byte to use the normal Write method. By implementing WriteString this extra copy isn't needed. Internall we don't do the copy and just use s2b instead.
9 lines
183 B
Go
9 lines
183 B
Go
package stackless
|
|
|
|
import "unsafe"
|
|
|
|
// s2b converts string to a byte slice without memory allocation.
|
|
func s2b(s string) []byte {
|
|
return unsafe.Slice(unsafe.StringData(s), len(s))
|
|
}
|