From 0322e9e1b9ff017f084555286d1569e88ecaf8a8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 15 Apr 2023 09:00:58 -0600 Subject: btrfsutil: RebuiltTree: Drop pointless `if`/indentation --- lib/btrfsutil/rebuilt_tree.go | 48 +++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/lib/btrfsutil/rebuilt_tree.go b/lib/btrfsutil/rebuilt_tree.go index d890dc4..70be4c8 100644 --- a/lib/btrfsutil/rebuilt_tree.go +++ b/lib/btrfsutil/rebuilt_tree.go @@ -216,33 +216,31 @@ nextKP: } indexer.node(ctx, kp.FromNode, stack) - if len(indexer.nodeToRoots[kp.FromNode]) > 0 { - for root, rootInfo := range indexer.nodeToRoots[kp.FromNode] { - if kp.FromSlot+1 < len(indexer.tree.forrest.graph.EdgesFrom[kp.FromNode]) { - rootInfo.loMaxItem = indexer.tree.forrest.graph.EdgesFrom[kp.FromNode][kp.FromSlot+1].ToKey.Mm() - rootInfo.hiMaxItem = rootInfo.loMaxItem - } else { - // OK, now check the MaxItem expectation. - // - // We'll use the hiMaxItem, because it only needs to be - // valid in *one* of the paths to this node. - kpMaxItem := rootInfo.hiMaxItem - if kpMaxItem.Compare(nodeInfo.MaxItem(indexer.tree.forrest.graph)) < 0 { - continue nextKP - } - } - oldRootInfo, ok := roots[root] - if ok && rootInfo.loMaxItem.Compare(oldRootInfo.loMaxItem) > 0 { - rootInfo.loMaxItem = oldRootInfo.loMaxItem - } - if ok && rootInfo.hiMaxItem.Compare(oldRootInfo.hiMaxItem) < 0 { - rootInfo.hiMaxItem = oldRootInfo.hiMaxItem - } - if roots == nil { - roots = make(rebuiltRoots) + for root, rootInfo := range indexer.nodeToRoots[kp.FromNode] { + if kp.FromSlot+1 < len(indexer.tree.forrest.graph.EdgesFrom[kp.FromNode]) { + rootInfo.loMaxItem = indexer.tree.forrest.graph.EdgesFrom[kp.FromNode][kp.FromSlot+1].ToKey.Mm() + rootInfo.hiMaxItem = rootInfo.loMaxItem + } else { + // OK, now check the MaxItem expectation. + // + // We'll use the hiMaxItem, because it only needs to be + // valid in *one* of the paths to this node. + kpMaxItem := rootInfo.hiMaxItem + if kpMaxItem.Compare(nodeInfo.MaxItem(indexer.tree.forrest.graph)) < 0 { + continue nextKP } - roots[root] = rootInfo } + oldRootInfo, ok := roots[root] + if ok && rootInfo.loMaxItem.Compare(oldRootInfo.loMaxItem) > 0 { + rootInfo.loMaxItem = oldRootInfo.loMaxItem + } + if ok && rootInfo.hiMaxItem.Compare(oldRootInfo.hiMaxItem) < 0 { + rootInfo.hiMaxItem = oldRootInfo.hiMaxItem + } + if roots == nil { + roots = make(rebuiltRoots) + } + roots[root] = rootInfo } } if roots == nil { -- cgit v1.2.3