FAQ
Hello,
According to David's pres (
http://go-talks.appspot.com/github.com/davecheney/presentations/writing-high-performance-go.slide#30)
<http://go-talks.appspot.com/github.com/davecheney/presentations/writing-high-performance-go.slide#30>,
if you want use []byte as map key, the compiler implements some
optimization (avoid the conversion []byte -> string) when you do this:

var m map[string]string
v, ok := m[string(bytes)]



but not:

key := string(bytes)
val, ok := m[key]



As net.IP is []byte, does the compiler implement the same optimization when
you do this :

var m map[string]string
val, ok := m[string(net.IPv4zero)]

or I have to do this:
var m map[string]string
val, ok := m[string([]byte(net.IPv4zero))]

Thx in adv (special thx to Dave for this pres and his kindness :) )
Jérôme

--
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 | 1 of 4 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedApr 17, '16 at 5:07p
activeApr 18, '16 at 7:46p
posts4
users2
websitegolang.org

2 users in discussion

Jérôme LAFORGE: 3 posts Jakob Borg: 1 post

People

Translate

site design / logo © 2022 Grokbase