]> Cypherpunks repositories - gostls13.git/commitdiff
internal/poll: rely on utf8.AppendRune
authorJoe Tsai <joetsai@digital-static.net>
Thu, 16 Jun 2022 00:35:41 +0000 (17:35 -0700)
committerGopher Robot <gobot@golang.org>
Mon, 22 Aug 2022 23:36:08 +0000 (23:36 +0000)
This is both simpler and more performant.

Change-Id: I398de29230e578fb7caf1765df7b8fe84d4e8876
Reviewed-on: https://go-review.googlesource.com/c/go/+/412336
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/internal/poll/fd_windows.go

index 1ca281b2a4a0613825705b5386108480595d3e22..1af2011f94d63ef3caab42657ef4ae0640554ed2 100644 (file)
@@ -500,8 +500,7 @@ func (fd *FD) readConsole(b []byte) (int, error) {
                                        }
                                }
                        }
-                       n := utf8.EncodeRune(buf[len(buf):cap(buf)], r)
-                       buf = buf[:len(buf)+n]
+                       buf = utf8.AppendRune(buf, r)
                }
                fd.readbyte = buf
                fd.readbyteOffset = 0