aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2016-03-01 14:52:18 -0800
committerIan Lance Taylor <iant@golang.org>2016-03-02 00:04:53 +0000
commit8b4deb448e587802f67930b765c9598fc8cd36e5 (patch)
tree40bb8ba92ea4f7b556f4a00b59aca21c8babc912
parent88e18032bd76656afcf246c1a252e04cf462b41e (diff)
downloadgo-8b4deb448e587802f67930b765c9598fc8cd36e5.tar.xz
cmd/compile: fix OADDSTR buffer size calculation
The size calculation has been wrong since this code was first committed in https://golang.org/cl/3120. The effect was that the compiler always allocated a temporary buffer on the stack for a non-escaping string concatenation. This turns out to make no practical difference, as the compiler always allocates a buffer of the same size (32 bytes) and the runtime only uses the temporary buffer if the concatenated strings fit (check is in rawstringtmp in runtime/string.go). The effect of this change is to avoid generating a temporary buffer on the stack that will not be used. Change-Id: Id632bfe3d6c113c9934c018a2dd4bcbf1784a63d Reviewed-on: https://go-review.googlesource.com/20112 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-rw-r--r--src/cmd/compile/internal/gc/walk.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go
index 7d4c697e7d..3e67f50620 100644
--- a/src/cmd/compile/internal/gc/walk.go
+++ b/src/cmd/compile/internal/gc/walk.go
@@ -2718,8 +2718,8 @@ func addstr(n *Node, init **NodeList) *Node {
if n.Esc == EscNone {
sz := int64(0)
for l := n.List; l != nil; l = l.Next {
- if n.Op == OLITERAL {
- sz += int64(len(n.Val().U.(string)))
+ if l.N.Op == OLITERAL {
+ sz += int64(len(l.N.Val().U.(string)))
}
}