From 3ca3e5c5ceeb8d12a9c3d0f14ead86620c7f7c03 Mon Sep 17 00:00:00 2001 From: "Eliyaan (Nopana)" <103932369+Eliyaan@users.noreply.github.com> Date: Wed, 30 Apr 2025 19:11:37 +0200 Subject: [PATCH] tools: use breadth first search in vreduce (#24369) --- cmd/tools/vreduce.v | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/tools/vreduce.v b/cmd/tools/vreduce.v index 792672b249..1aa05860bc 100644 --- a/cmd/tools/vreduce.v +++ b/cmd/tools/vreduce.v @@ -94,11 +94,11 @@ fn main() { } // Return true if the command ran on the file produces the pattern -fn string_reproduces(file string, pattern string, command string, path string, debug bool, timeout int) bool { +fn string_reproduces(file_content string, pattern string, command string, dir string, debug bool, timeout int) bool { if !os.exists(tmp_folder) { os.mkdir(tmp_folder) or { panic(err) } } - os.write_file(path, file) or { panic(err) } + os.write_file(dir, file_content) or { panic(err) } mut output := '' if timeout == 0 { res := os.execute(command) @@ -330,7 +330,7 @@ fn reduce_scope(content string, error_msg string, command string, do_fmt bool, p show_code_stats(code) } else { // if can remove it, no need to go though it's children for i in 0 .. item.children.len { - stack << &item.children[i] + stack.insert(0, &item.children[i]) // breadth first search } } }