News for hackers. Stuff that matters.
Re:Making a Go program 70% faster with a one character change by dleslie on Monday November 14, 2022 @12:48PM (#33597961)
I would also lay a chunk of blame on the use of type inference which causes the information about the behaviour to be hidden from view.

Had the author been looking at the type information within the syntax of the code the profile output may not have been a surprise. Perhaps the problem would never have existed in the first place.

Re:Making a Go program 70% faster with a one character change by adrianmonk on Monday November 14, 2022 @02:51PM (#33599926)
Yeah. Often, writing out the type explicitly is just busywork. But it seems it would have paid off here.

If you were forced to stop and think what type to declare, I bet you'd write "var rule *Rule". Even if you don't think deeply and just look at the return type.

And then if you assigned "r[i]" to "rule", you'd get a type error.