Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Access to uint64 pair? #214

Open
brycekahle opened this issue Aug 23, 2021 · 5 comments
Open

Access to uint64 pair? #214

brycekahle opened this issue Aug 23, 2021 · 5 comments

Comments

@brycekahle
Copy link

We serialize a lot of IP addresses, and rather than converting the internal uint64 pair to byte arrays and then back to uint64s, it would be great if we could get access to the uint64 pair values directly to use them for serialization. Also, the ability to construct a netaddr.IP from a uint64 pair would be useful for de-serialization.

@danderson
Copy link
Member

I'm -1 on this, because not exposing internal implementation details has allowed us to change the internal representation 3 times so far, with huge benefits each time.

What kind of serialization are you doing? I'm curious why a pair of uint64s is significantly better than being able to get a [16]byte.

@bradfitz
Copy link
Contributor

Also: numbers?

@brycekahle
Copy link
Author

I'm -1 on this, because not exposing internal implementation details

Fair enough.

What kind of serialization are you doing?

Protobuf.

why a pair of uint64s is significantly better than being able to get a [16]byte

Because we don't want to spend the cost of converting the uint64 pair to [16]byte on every IP address, if we don't have to.

@dsnet
Copy link
Collaborator

dsnet commented Aug 24, 2021

This seems like a compiler optimization issue:

@josharian
Copy link
Collaborator

It's unfortunate that As16 is not inlineable.

I'll send a PR for golang/go#42958. I don't know that it'll get accepted, though.

the compiler should realize that...

If it doesn't do this already (it might), then the relevant issue is probably golang/go#24416.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants