From: Russ Cox Date: Wed, 27 Jun 2012 21:06:49 +0000 (-0400) Subject: runtime: avoid allocation for "" + x + "" X-Git-Tag: go1.1rc2~2865 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8744d35dd3429b175559ca89799858b1fd497bcb;p=gostls13.git runtime: avoid allocation for "" + x + "" R=golang-dev, r CC=golang-dev https://golang.org/cl/6359043 --- diff --git a/src/pkg/runtime/string.goc b/src/pkg/runtime/string.goc index 090c4cd20e..8a5d59b81d 100644 --- a/src/pkg/runtime/string.goc +++ b/src/pkg/runtime/string.goc @@ -141,15 +141,22 @@ runtime·catstring(String s1, String s2) static String concatstring(int32 n, String *s) { - int32 i, l; + int32 i, l, count; String out; l = 0; + count = 0; for(i=0; i 0) { + count++; + out = s[i]; + } } + if(count <= 1) // zero or one non-empty string in concatenation + return out; out = gostringsize(l); l = 0;