]> Cypherpunks repositories - gostls13.git/commit
os: avoid allocation in File.WriteString
authorJosh Bleecher Snyder <josharian@gmail.com>
Sat, 7 Nov 2020 01:37:03 +0000 (17:37 -0800)
committerJosh Bleecher Snyder <josharian@gmail.com>
Thu, 25 Feb 2021 19:42:00 +0000 (19:42 +0000)
commit526ee96f4992ff3a1e1c219fe8dc9870098bacba
treed7d8d1101ef6e6bfbef121be116694509e115bdf
parent194b636f8f1ff7d6b709b5b9010d1d14b3919e66
os: avoid allocation in File.WriteString

Instead of alloc+copy to convert the string
to a byte slice, do an unsafe conversion.

Rely on the kernel not to scribble on the
buffer during the write.

Fixes #42406

Change-Id: I66f4838b43a11bcc3d67bbfa1706726318d55343
Reviewed-on: https://go-review.googlesource.com/c/go/+/268020
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
src/os/file.go
src/os/os_test.go