could anybody tell me where to find golang implicit optimize?

182 views
Skip to first unread message

cheng dong

unread,
Jul 22, 2021, 9:57:47 PM7/22/21
to golang-nuts
1. if a function's signature is f `func([]byte)` and we have a string s, then when we call `f([]byte(s))` golang wont create a []byte then copy, in opposite, golang will use the internal byte slice in string.
2. if we use a for range to set every item in  slice to a const value, then the for range will be auto turn to memset.

i want to know where i can find all these language optimize, so avoid to do useless human opt again.

Ian Lance Taylor

unread,
Jul 23, 2021, 12:44:21 AM7/23/21
to cheng dong, golang-nuts
As far as I know there is no general description of all compiler
optimizations in any useful form. Sorry.

Ian

cheng dong

unread,
Jul 23, 2021, 1:17:45 AM7/23/21
to golang-nuts
thanks for reply

regards
cheng

Ross Light

unread,
Jul 24, 2021, 10:59:02 PM7/24/21
to golang-nuts
I have no idea how well-maintained this page is, but there is https://github.com/golang/go/wiki/CompilerOptimizations
Reply all
Reply to author
Forward
0 new messages