commit | 6edd7971bb3e83356544b2cd6e7a93fdabff1246 | [log] [tgz] |
---|---|---|
author | Cuong Manh Le <cuong.manhle.vn@gmail.com> | Wed Apr 01 05:27:49 2020 +0700 |
committer | Matthew Dempsky <mdempsky@google.com> | Tue Mar 31 23:39:12 2020 +0000 |
tree | 97f17bb5205184633e5dc765db35f5de9090d50d | |
parent | 82253ddc7a6b85240fd74cc5138f685ca931f355 [diff] |
cmd/compile: optimize len check when make slice In CL 226278, we did: if len < 0 { panicmakeslicelen } if len > cap { panicmakeslicecap } But due to the fact that cap is constrained to [0,2^31), so it is safe to do: if uint64(len) > cap { if len < 0 { panicmakeslicelen() } panicmakeslicecap() } save us a comparison in common case when len is within range. Passes toolstash-check. Change-Id: I0ebd52914ccde4cbb45f16c9e020b0c8f42e0663 Reviewed-on: https://go-review.googlesource.com/c/go/+/226737 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 3.0 Attributions license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Official binary distributions are available at https://golang.org/dl/.
After downloading a binary release, visit https://golang.org/doc/install or load doc/install.html in your web browser for installation instructions.
If a binary distribution is not available for your combination of operating system and architecture, visit https://golang.org/doc/install/source or load doc/install-source.html in your web browser for source installation instructions.
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines: https://golang.org/doc/contribute.html
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://golang.org/wiki/Questions for a list of places to ask questions about the Go language.