compiler: optimize string concatenations

Programming / Compilers / GCC - ian [138bc75d-0d04-0410-961f-82ee72b054a4] - 19 June 2019 15:13 EDT

runtime.concatstring{2,3,4,5} are just wrappers of concatstrings. These wrappers don't provide any benefit, at least in the C calling convention we use, where passing arrays by value isn't an efficient thing. Change it to always use concatstrings.

Also, the cap field of the slice passed to concatstrings is not necessary. So change it to pass a pointer and a length directly, which is more efficient than passing a slice header by value.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/182539

85c94669b9e compiler: optimize string concatenations
gcc/go/gofrontend/MERGE | 2 +-
gcc/go/gofrontend/expressions.cc | 68 ++++++++++------------------------------
gcc/go/gofrontend/runtime.def | 12 ++-----
libgo/go/runtime/string.go | 24 ++------------
4 files changed, 23 insertions(+), 83 deletions(-)

Upstream: gcc.gnu.org


  • Share