fix: fix CountStats performance by apocelipes · Pull Request #626 · boyter/scc
Yeah annoying.
@boyter Finally, I found what caused this. Even if the functions are inlined, their arguments are evaluated, so that we need to pay time to convert arguments to interface any. Converting to any is slow but if we use outside if-statements to skip the whole block, the cost will not be paied. The Golang compiler currently has only very limited optimizations, and it doesn't seem to be able to handle the above situation.
P.S. Even though converting arguments to any is slow, printXXXF(“%s %d”, s1, i1) is still much faster than printXXX(fmt.Sprintf(“%s %d”, s1, i1)).