diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-04 01:11:17 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-12 16:16:53 -0700 |
commit | 6d62529a4badae01b4b1c22dbf3f0e462a908a0b (patch) | |
tree | 0601702b58a86739de67dae088fe5d372358d413 /lib/btrfsprogs/btrfsinspect/print_tree.go | |
parent | 1b84ddb5c9f8f4f1654feb50b4086fdcd9be7597 (diff) |
tree-wide: Cache all calls to binstruct.StaticSize
Diffstat (limited to 'lib/btrfsprogs/btrfsinspect/print_tree.go')
-rw-r--r-- | lib/btrfsprogs/btrfsinspect/print_tree.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/print_tree.go b/lib/btrfsprogs/btrfsinspect/print_tree.go index 409ce0c..8acf9cc 100644 --- a/lib/btrfsprogs/btrfsinspect/print_tree.go +++ b/lib/btrfsprogs/btrfsinspect/print_tree.go @@ -92,6 +92,8 @@ func DumpTrees(ctx context.Context, out io.Writer, fs *btrfs.FS) { textui.Fprintf(out, "uuid %v\n", superblock.FSUUID) } +var nodeHeaderSize = binstruct.StaticSize(btrfstree.NodeHeader{}) + // printTree mimics btrfs-progs // kernel-shared/print-tree.c:btrfs_print_tree() and // kernel-shared/print-tree.c:btrfs_print_leaf() @@ -100,7 +102,7 @@ func printTree(ctx context.Context, out io.Writer, fs *btrfs.FS, treeID btrfspri handlers := btrfstree.TreeWalkHandler{ Node: func(path btrfstree.TreePath, nodeRef *diskio.Ref[btrfsvol.LogicalAddr, btrfstree.Node]) error { printHeaderInfo(out, nodeRef.Data) - itemOffset = nodeRef.Data.Size - uint32(binstruct.StaticSize(btrfstree.NodeHeader{})) + itemOffset = nodeRef.Data.Size - uint32(nodeHeaderSize) return nil }, PreKeyPointer: func(_ btrfstree.TreePath, item btrfstree.KeyPointer) error { |