diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-13 21:22:14 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-13 21:39:42 -0600 |
commit | 72a458520fccafe4df8c02c811cb6f64a310616e (patch) | |
tree | 1c424b5376c31524b01f8461b02950eb04d48345 /lib/btrfs | |
parent | 952b677bf7f10da93673e3671f764c54c454bbfe (diff) |
Move the remaining former-generic.go parts out of lib/util/
Diffstat (limited to 'lib/btrfs')
-rw-r--r-- | lib/btrfs/btrfsvol/chunk.go | 9 | ||||
-rw-r--r-- | lib/btrfs/btrfsvol/devext.go | 6 | ||||
-rw-r--r-- | lib/btrfs/io3_btree.go | 3 | ||||
-rw-r--r-- | lib/btrfs/io4_fs.go | 6 |
4 files changed, 14 insertions, 10 deletions
diff --git a/lib/btrfs/btrfsvol/chunk.go b/lib/btrfs/btrfsvol/chunk.go index 2d26964..9c77a49 100644 --- a/lib/btrfs/btrfsvol/chunk.go +++ b/lib/btrfs/btrfsvol/chunk.go @@ -8,7 +8,8 @@ import ( "fmt" "sort" - "git.lukeshu.com/btrfs-progs-ng/lib/util" + "git.lukeshu.com/btrfs-progs-ng/lib/maps" + "git.lukeshu.com/btrfs-progs-ng/lib/slices" ) // logical => []physical @@ -51,8 +52,8 @@ func (a chunkMapping) union(rest ...chunkMapping) (chunkMapping, error) { beg := chunks[0].LAddr end := chunks[0].LAddr.Add(chunks[0].Size) for _, chunk := range chunks { - beg = util.Min(beg, chunk.LAddr) - end = util.Max(end, chunk.LAddr.Add(chunk.Size)) + beg = slices.Min(beg, chunk.LAddr) + end = slices.Max(end, chunk.LAddr.Add(chunk.Size)) } ret := chunkMapping{ LAddr: beg, @@ -78,7 +79,7 @@ func (a chunkMapping) union(rest ...chunkMapping) (chunkMapping, error) { }] = struct{}{} } } - ret.PAddrs = util.MapKeys(paddrs) + ret.PAddrs = maps.Keys(paddrs) sort.Slice(ret.PAddrs, func(i, j int) bool { return ret.PAddrs[i].Cmp(ret.PAddrs[j]) < 0 }) diff --git a/lib/btrfs/btrfsvol/devext.go b/lib/btrfs/btrfsvol/devext.go index 1f6cabe..83ece99 100644 --- a/lib/btrfs/btrfsvol/devext.go +++ b/lib/btrfs/btrfsvol/devext.go @@ -7,7 +7,7 @@ package btrfsvol import ( "fmt" - "git.lukeshu.com/btrfs-progs-ng/lib/util" + "git.lukeshu.com/btrfs-progs-ng/lib/slices" ) // physical => logical @@ -48,8 +48,8 @@ func (a devextMapping) union(rest ...devextMapping) (devextMapping, error) { beg := exts[0].PAddr end := beg.Add(exts[0].Size) for _, ext := range exts { - beg = util.Min(beg, ext.PAddr) - end = util.Max(end, ext.PAddr.Add(ext.Size)) + beg = slices.Min(beg, ext.PAddr) + end = slices.Max(end, ext.PAddr.Add(ext.Size)) } ret := devextMapping{ PAddr: beg, diff --git a/lib/btrfs/io3_btree.go b/lib/btrfs/io3_btree.go index e7c6cc2..f476dae 100644 --- a/lib/btrfs/io3_btree.go +++ b/lib/btrfs/io3_btree.go @@ -15,6 +15,7 @@ import ( "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsitem" "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol" + "git.lukeshu.com/btrfs-progs-ng/lib/slices" "git.lukeshu.com/btrfs-progs-ng/lib/util" ) @@ -653,7 +654,7 @@ func (fs *FS) TreeSearchAll(treeID ObjID, fn func(Key) int) ([]Item, error) { } ret = append(ret, prevItem) } - util.ReverseSlice(ret) + slices.Reverse(ret) for nextPath, nextNode := middlePath, middleNode; true; { nextPath, nextNode, err = fs.next(nextPath, nextNode) if err != nil { diff --git a/lib/btrfs/io4_fs.go b/lib/btrfs/io4_fs.go index eaa83f7..cae2771 100644 --- a/lib/btrfs/io4_fs.go +++ b/lib/btrfs/io4_fs.go @@ -17,6 +17,8 @@ import ( "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsitem" "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol" "git.lukeshu.com/btrfs-progs-ng/lib/containers" + "git.lukeshu.com/btrfs-progs-ng/lib/maps" + "git.lukeshu.com/btrfs-progs-ng/lib/slices" "git.lukeshu.com/btrfs-progs-ng/lib/util" ) @@ -246,7 +248,7 @@ func (ret *Dir) populate() { ret.ChildrenByName[string(entry.Name)] = entry } } - for _, name := range util.SortedMapKeys(ret.ChildrenByName) { + for _, name := range maps.SortedKeys(ret.ChildrenByName) { if _, exists := entriesWithIndexes[name]; !exists { ret.Errs = append(ret.Errs, fmt.Errorf("missing by-index direntry for %q", name)) ret.ChildrenByIndex[nextIndex] = ret.ChildrenByName[name] @@ -377,7 +379,7 @@ func (file *File) maybeShortReadAt(dat []byte, off int64) (int, error) { continue } offsetWithinExt := off - extent.OffsetWithinFile - readSize := util.Min(int64(len(dat)), extLen-offsetWithinExt) + readSize := slices.Min(int64(len(dat)), extLen-offsetWithinExt) switch extent.Type { case btrfsitem.FILE_EXTENT_INLINE: return copy(dat, extent.BodyInline[offsetWithinExt:offsetWithinExt+readSize]), nil |