chore: update to use iterators on orderedmaps

This commit is contained in:
Tristan Cartledge
2024-08-14 12:10:07 +01:00
committed by quobix
parent c3eb16d4e4
commit 161a41f73b
73 changed files with 690 additions and 550 deletions

View File

@@ -94,9 +94,9 @@ func (p *Paths) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.
p.PathItems = pathsMap
for pm := pathsMap.First(); pm != nil; pm = pm.Next() {
for k, v := range pathsMap.FromOldest() {
// add path as node to path item, not this path object.
pm.Value().Value.Nodes.Store(pm.Key().KeyNode.Line, pm.Key().KeyNode)
v.Value.Nodes.Store(k.KeyNode.Line, k.KeyNode)
}
return nil
@@ -105,9 +105,7 @@ func (p *Paths) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.
// Hash will return a consistent SHA256 Hash of the PathItem object
func (p *Paths) Hash() [32]byte {
var f []string
for pair := orderedmap.First(orderedmap.SortAlpha(p.PathItems)); pair != nil; pair = pair.Next() {
f = append(f, fmt.Sprintf("%s-%s", pair.Key().Value, low.GenerateHashString(pair.Value().Value)))
}
f = low.AppendMapHashes(f, p.PathItems)
f = append(f, low.HashExtensions(p.Extensions)...)
return sha256.Sum256([]byte(strings.Join(f, "|")))
}