-
Notifications
You must be signed in to change notification settings - Fork 17.7k
CompilerOptimizations
Josh Bleecher Snyder edited this page Feb 4, 2015
·
19 revisions
This page lists optimizations done by the compilers. Note that these are not guaranteed by the language specification.
Putting a zero-width type in an interface value doesn't allocate.
- gc: 1.0+
- gccgo: ?
Putting a word-sized-or-less non-pointer type in an interface value doesn't allocate.
- gc: 1.0-1.3, but not in 1.4+
- gccgo: never
For a map m of type map[string]T and []byte b, m[string(b)] doesn't allocate. (the temporary string copy of the byte slice isn't made)
- gc: 1.4+
- gccgo: ?
TODO
For a slice or array s, loops of the form
for i := range s {
a[i] = <zero value for element of s>
}
are converted into efficient runtime memclr calls. Issue and commit.
- gc: 1.5+
- gccgo: ?