[go] syscall: copy only read bytes in js/wasm

0 views
Skip to first unread message

Cherry Mui (Gerrit)

unread,
11:14 AM (2 hours ago) 11:14 AM
to Rajiv Singh, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Hyang-Ah Hana Kim, Johan Brandhorst-Satzkorn, golang...@luci-project-accounts.iam.gserviceaccount.com, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

Cherry Mui submitted the change

Change information

Commit message:
syscall: copy only read bytes in js/wasm

CopyBytesToGo in Read and Pread copies the entire buffer instead of
only the n bytes actually returned by the read call. This is wasteful,
especially for small files where os.ReadFile uses a 512-byte buffer
but only a few bytes are read.

Copy only the bytes that were read, and skip the copy entirely when
zero bytes are returned.

Fixes #53566
Change-Id: I3109db5e8afe4f5ea53c9c0aa2724ff60e883ec1
Reviewed-by: Cherry Mui <cher...@google.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.br...@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hya...@gmail.com>
Files:
  • M src/syscall/fs_js.go
Change size: S
Delta: 1 file changed, 9 insertions(+), 4 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I3109db5e8afe4f5ea53c9c0aa2724ff60e883ec1
Gerrit-Change-Number: 767680
Gerrit-PatchSet: 3
Gerrit-Owner: Rajiv Singh <rajivpe...@gmail.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Johan Brandhorst-Satzkorn <johan.br...@gmail.com>
Gerrit-Reviewer: Sean Liao <se...@liao.dev>
Gerrit-CC: Gopher Robot <go...@golang.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages