Open marten-seemann opened 1 year ago
Another annoyance I ran into: Component
doesn't implement the Multiaddr interface. So if you collect a bunch into a slice: []Components
there's no way to join them all. I'm not sure if we even need the component in the new API, just wanted to mention it as another pain point.
Problems with the current API
Major problems:
Related: https://github.com/multiformats/multiaddr/issues/155
Minor problems:
Multiaddr
is an interface, and therefore (almost always) allocated on the heap. This creates a lot of GC pressure.SplitLast
) and methods on the interface (e.g.ValueForProtocol
). There’s no (apparent) logic behind this, making use of the API confusingProtocols
) is the major source of allocations in a Kubo nodeProposal for a new API
Wishlist
Multiaddr
is not an interface any more, but a concrete typeMultiaddr
can be entirely allocated on the stackMultiaddr
are comparable using the==
operator. This means they can be used as map keys!Component
is a concrete type, also allocated on the stack, and==
comparable