On Thursday, 16 June 2016 10:11:12 UTC+7, Nigel Tao wrote:
On Thu, Jun 16, 2016 at 11:22 AM, <gordo...@gmail.com <javascript:>>
it no longer does the array bounds check twice
It's not safe, but you might want to try disabling bounds checking by
"go tool compile -B" or "go build -gcflags=-B"
In fact, in this case it is safe because the loop code has a built-in array
check in checking that the 'j' variable doesn't go past the top of the
array (and in the enclosing loop that the 'i' index doesn't go past the
index of the square root of the top value), which array is sized to contain
that top array index.

I am not currently at my usual test machine so will wait a few hours to
post the results, but I would assume that just the two instruction array
bounds check, which takes about two CPU clock cycles, will be eliminated,
thus it is likely that the run time twill be reduced to about two thirds
for a modern desktop CPU. This will still likely be slightly slower than
optimized C/C++ code for the reasons given in my last post, but not bad at

It's too bad one can't disable bounds checks only for certain ranges of
code by "pragma"'s in the source code, but I don't suppose that is possible.

You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 7 of 27 | next ›
Discussion Overview
groupgolang-nuts @
postedJun 14, '16 at 12:31p
activeJun 18, '16 at 10:54a



site design / logo © 2021 Grokbase