Re: [go-nuts] Re: Eliminating redundant map lookups

2016-11-27 Thread 'Keith Randall' via golang-nuts
Yes, it currently requires two lookups (two hashes, two bucket searches, etc.). This general problem is issue 17133 (https://github.com/golang/go/issues/17133). Your example has the extra complication that the update operation is an append, not just a +=. On Sunday, November 27, 2016 at 7:00

Re: [go-nuts] CFG for a Go program

2016-11-26 Thread 'Keith Randall' via golang-nuts
You can get the CFG (control flow graph) for a function by setting the environment variable GOSSAFUNC to the function in question when building. It will generate a file named ssa.html in the current directory which you can load into a browser. It doesn't draw the CFG explicitly but the nodes (b

[go-nuts] Re: Concurrently read map entries into a channel

2016-11-05 Thread 'Keith Randall' via golang-nuts
On Saturday, November 5, 2016 at 7:48:27 AM UTC-7, leob...@gmail.com wrote: > > Hey, > > I have a scenario where I need to iterate over (as many as possible) map > entries and send them into a channel. > The operation on the other end of the channel can take a long time, so > sends on the chann

[go-nuts] Re: Two Related Questions. (1) Map Concurrency (2) Making Multidimensional Arrays

2016-09-12 Thread 'Keith Randall' via golang-nuts
Tamás's suggestion of using [4]string as the key is a good one. You could use any struct you want as well, if you want to name the parts of the key. How are you using the map? If you're only reading the map, then concurrent access is allowed. Concurrent access is only forbidden if one of the

Re: [go-nuts] Will go compiler do optimization here if "bytes" is a global variable?

2016-07-25 Thread 'Keith Randall' via golang-nuts
Yes, it is. The optimization occurs for any occurrence of m[string(expression of type []byte)]. Where the byte slice came from (global or otherwise) is irrelevant. On Monday, July 25, 2016 at 8:37:03 AM UTC-7, T L wrote: > > @Randall, thanks for answer. > You mean the answer is yes, right? --

Re: [go-nuts] Will go compiler do optimization here if "bytes" is a global variable?

2016-07-23 Thread 'Keith Randall' via golang-nuts
This was a concern when we originally implemented the m[string(b)] optimization. If someone is simultaneously modifying b, then weird things happen during the lookup. But it won't crash anything, just maybe not return what you expect. And that's ok in cases of a data race, the spec makes no

Re: [go-nuts] [ANN] primegen.go: Sieve of Atkin prime number generator

2016-06-20 Thread 'Keith Randall' via golang-nuts
On Monday, June 20, 2016 at 6:33:29 AM UTC-7, gordo...@gmail.com wrote: > > Further to the subject of compiler efficiency, the following is the > assembler code output with array bounds checking turned off (-B) the the > inner tight composite culling loop of FasterEratspeed above (generated wit

Re: [go-nuts] Re: [ANN] primegen.go: Sieve of Atkin prime number generator

2016-06-16 Thread 'Keith Randall' via golang-nuts
Looks like something is wrong with immediate loading for the 1 << ... operation. Could you open a bug with repro instructions? I can look at it when 1.8 opens. On Thursday, June 16, 2016 at 5:30:12 PM UTC-7, gordo...@gmail.com wrote: > > > Modern x86 CPUs don't work like that. > > > In genera

Re: [go-nuts] Bitmasks on signed types

2016-06-15 Thread &#x27;Keith Randall&#x27; via golang-nuts
I do x & (0x - 1<<32). On Tuesday, June 14, 2016 at 1:44:14 PM UTC-7, Michael Jones wrote: > > I have fought this many times. > > What I almost always do is cast all variables involved as unsigned so that > I can express the logical operations as desired. The exception is right > shift

<    1   2