News for hackers. Stuff that matters.
Re:A year with Go by jusssi on Saturday June 06, 2015 @05:03AM (#9670198)
There are cases where the Go compiler generates horrors, and the only workaround is to write your code in asm.

Here's one example:

// imagine a for-loop around this

s := foo[i:i+4]

s[3], s[2], s[1], s[0] = s[0], s[1], s[2], s[3]

The reasonable assumption is that the second line generates either zero, one, or four bounds checks on s. However, the Go compiler likes to be sure, and turns it into 8 bounds checks.

I agree it's not a typical for a server to spend the majority of it's time swapping bytes. In the rare case that happens, you're going to hate the compiler for not being smarter.

EDIT: fixed formatting of the example

There are no comments on this comment yet.