From 7fba10e5be51a3fe565a6f69a946ece9f0e59a67 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 5 Sep 2022 12:43:46 -0600 Subject: Try to uniformly use containers.Set --- lib/btrfs/btrfsvol/lvm.go | 2 ++ lib/btrfs/io4_fs.go | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/btrfs') diff --git a/lib/btrfs/btrfsvol/lvm.go b/lib/btrfs/btrfsvol/lvm.go index 8003466..e12e53e 100644 --- a/lib/btrfs/btrfsvol/lvm.go +++ b/lib/btrfs/btrfsvol/lvm.go @@ -256,6 +256,8 @@ func (lv *LogicalVolume[PhysicalVolume]) Mappings() []Mapping { return ret } +// paddrs isn't a containers.Set because QualifiedPhysicalAddr is not +// an ordered type. func (lv *LogicalVolume[PhysicalVolume]) Resolve(laddr LogicalAddr) (paddrs map[QualifiedPhysicalAddr]struct{}, maxlen AddrDelta) { node := lv.logical2physical.Search(func(chunk chunkMapping) int { return chunkMapping{LAddr: laddr, Size: 1}.cmpRange(chunk) diff --git a/lib/btrfs/io4_fs.go b/lib/btrfs/io4_fs.go index 8751078..82d4c87 100644 --- a/lib/btrfs/io4_fs.go +++ b/lib/btrfs/io4_fs.go @@ -248,13 +248,13 @@ func (ret *Dir) populate() { panic(fmt.Errorf("TODO: handle item type %v", item.Key.ItemType)) } } - entriesWithIndexes := make(map[string]struct{}) + entriesWithIndexes := make(containers.Set[string]) nextIndex := uint64(2) for index, entry := range ret.ChildrenByIndex { if index+1 > nextIndex { nextIndex = index + 1 } - entriesWithIndexes[string(entry.Name)] = struct{}{} + entriesWithIndexes.Insert(string(entry.Name)) if other, exists := ret.ChildrenByName[string(entry.Name)]; !exists { ret.Errs = append(ret.Errs, fmt.Errorf("missing by-name direntry for %q", entry.Name)) ret.ChildrenByName[string(entry.Name)] = entry @@ -264,7 +264,7 @@ func (ret *Dir) populate() { } } for _, name := range maps.SortedKeys(ret.ChildrenByName) { - if _, exists := entriesWithIndexes[name]; !exists { + if !entriesWithIndexes.Has(name) { ret.Errs = append(ret.Errs, fmt.Errorf("missing by-index direntry for %q", name)) ret.ChildrenByIndex[nextIndex] = ret.ChildrenByName[name] nextIndex++ -- cgit v1.2.3-2-g168b