• Eric Myhre's avatar
    Move selector.PathSegment up to ipld.PathSegment. · fc1f83d7
    Eric Myhre authored
    ipld.Path is now a slice of ipld.PathSegment instead of strings.
    
    This should be an improvement in sanity: there are now several fewer
    places importing "strconv", and that's just always a good thing.
    
    We will also be free in the future to add PathSegment-based accessor
    methods to ipld.Node, as has already been commented as a desire;
    and, to use PathSegment in building better typed errors
    (which is the specific thing that provokes this diff today and now).
    
    The implementation of PathSegment is now also based on a struct-style
    union rather than an interface style union.  There are comments about
    this in the diff.  I do not wish to comment on how much time I've spent
    looking at golang assembler and runtime internals while trying to find
    a path to a more perfect compromise between ergonomics and performance.
    tl;dr Selectors will probably get faster and trigger fewer allocations;
    ipld.Path will probably take slightly more memory (another word per
    path segment), but not enough to care about for any practical purposes.
    
    I did not attempt to hoist the SegmentIterator features from the
    selector package to anywhere more central.
    It may be a fine idea to do so someday; I just don't presently have
    a formed opinion and am not budgeting time to consider it today.
    Signed-off-by: default avatarEric Myhre <hash@exultant.us>
    fc1f83d7
node.go 9.33 KB