FAQ

On Thursday, 1 November 2012 17:28:51 UTC+1, Michael Jones wrote:

{
sp := &exact.stack[k]
columns = sp.columns
c = sp.c
r = sp.r
}
Wow, I never would have thought of doing something like that (including the
manual scoping). Do you have a blog or a summary page where you collect
micro-optimisations like this? Preferably with the reasoning that made you
discover them in the first place? It seems to be kind of your thing.
On Thursday, 1 November 2012 17:53:59 UTC+1, Peter wrote:

Is it necessarily slower?

A compiler could reasonably see that k is not changed and only do bounds
checking once.

Explicit and fast are both good Go principles :)
Do any of the Go compilers do any optimisations that involve avoiding
unnecessary bounds checking? And what do you consider reasonable? I
wouldn't expect this to be optimised:

columns = exact.stack[k].columns
c = exact.stack[k].c
r = exact.stack[k].r

But this seems a bit more likely to me:

columns, c, r = stack[k].columns, stack[k].c, stack[k].r

... since I think the evaluation of the left and right side could
reasonably be micro-optimised.

--

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 18 of 22 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 31, '12 at 9:15a
activeNov 2, '12 at 7:51a
posts22
users11
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase