tl;dr: on 64-bit little-endian machines, does

    x := math.Float64frombits(binary.LittleEndian.Uint64(byteSlice[:8]))

get optimized to a single move instruction from byteSlice[:8] to x?


Background info:

I'm currently writing a bunch of code that unmarshals binary data. A small 
example is this that unmarshals eight float64s 
<https://github.com/twpayne/go-shapefile/blob/9d0389566e789784d6f977e2da00c33b98b52ab2/shapefile.go#L307-L314>,
 
and a longer example is this that unmarshals an arbitrary number of float64s 
<https://github.com/twpayne/go-shapefile/blob/9d0389566e789784d6f977e2da00c33b98b52ab2/byteslicereader.go#L41-L44>.
 
In theory, when the endianness of the binary data matches the endianness of 
the architecture, these should become simple memory copies. Does Go 1.19 do 
this?

Although this is a performance question, performance is not a concern in my 
use case. This is just an idle "can Go do this yet?" question and I'm 
curious about the answer.


Thanks for any insight,
Tom

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e60948d1-8907-47ee-bdc5-1f344a21b5e2n%40googlegroups.com.

Reply via email to