summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2026-01-02 14:45:28 -0600
committerJohn Estabrook <jestabro@vyos.io>2026-02-06 14:42:47 -0600
commit03799d0a93e4a7eb5790836f50cb4a1188c360b6 (patch)
treefb2e81cf138d53f65e0af6ca8ef2d1f492eecd8c /src
parent6cf3918875b11dd94f9dc380b4083cc4258da74c (diff)
downloadvyos1x-config-03799d0a93e4a7eb5790836f50cb4a1188c360b6.tar.gz
vyos1x-config-03799d0a93e4a7eb5790836f50cb4a1188c360b6.zip
T8232: simplify return value of fold_tree_with_path
The details do not need to be exposed in the function signature.
Diffstat (limited to 'src')
-rw-r--r--src/config_diff.ml2
-rw-r--r--src/config_tree.ml2
-rw-r--r--src/reference_tree.ml2
-rw-r--r--src/vytree.ml6
-rw-r--r--src/vytree.mli2
5 files changed, 8 insertions, 6 deletions
diff --git a/src/config_diff.ml b/src/config_diff.ml
index 54f6474..5d71c34 100644
--- a/src/config_diff.ml
+++ b/src/config_diff.ml
@@ -330,7 +330,7 @@ let get_tagged_delete_tree dt =
else
(p, a)
in
- snd (Vytree.fold_tree_with_path f ([], del_tree) del_tree)
+ Vytree.fold_tree_with_path f ([], del_tree) del_tree
(* the following builds a diff_func to return a unified diff string of
diff --git a/src/config_tree.ml b/src/config_tree.ml
index a2bde3a..2f7d814 100644
--- a/src/config_tree.ml
+++ b/src/config_tree.ml
@@ -274,7 +274,7 @@ let value_paths_of_tree node =
q'::acc
in List.fold_left f a vs
in (p, a')
- in List.rev (snd (Vytree.fold_tree_with_path (func node) ([], []) node))
+ in List.rev (Vytree.fold_tree_with_path (func node) ([], []) node)
let prune_delete node path =
(* raises:
diff --git a/src/reference_tree.ml b/src/reference_tree.ml
index 81e45cf..d76c480 100644
--- a/src/reference_tree.ml
+++ b/src/reference_tree.ml
@@ -933,7 +933,7 @@ let validate_tree_filter dir rt ct =
List.fold_left try_validate (p, (ctree, out)) l'
in
let tree, out =
- snd (Vytree.fold_tree_with_path validate_path_filter ([], (ct, "")) ct)
+ Vytree.fold_tree_with_path validate_path_filter ([], (ct, "")) ct
in
tree, out
diff --git a/src/vytree.ml b/src/vytree.ml
index a65fe6f..7c4e4fb 100644
--- a/src/vytree.ml
+++ b/src/vytree.ml
@@ -292,7 +292,8 @@ let is_terminal_path node path =
| _ -> false
with Nonexistent_path -> false
-let rec fold_tree_with_path f (p', a) t =
+let fold_tree_with_path f (p', a) t =
+ let rec fold_func f (p', a) t =
let p =
match name_of_node t with
| "" -> p'
@@ -302,5 +303,6 @@ let rec fold_tree_with_path f (p', a) t =
match children with
| [] -> (Util.drop_first p), snd (f (p, a) t)
| c -> let res =
- List.fold_left (fold_tree_with_path f) (f (p, a) t) c in
+ List.fold_left (fold_func f) (f (p, a) t) c in
(Util.drop_first p), snd res
+ in snd (fold_func f (p', a) t)
diff --git a/src/vytree.mli b/src/vytree.mli
index c23f1a7..023d967 100644
--- a/src/vytree.mli
+++ b/src/vytree.mli
@@ -95,4 +95,4 @@ val move : 'a t -> string list -> position -> 'a t
val is_terminal_path : 'a t -> string list -> bool
[@@alert exn "Vytree.Empty_path"]
-val fold_tree_with_path: (string list * 'acc -> 'b t -> string list * 'acc) -> string list * 'acc -> 'b t -> string list * 'acc
+val fold_tree_with_path: (string list * 'acc -> 'b t -> string list * 'acc) -> string list * 'acc -> 'b t -> 'acc