Skip to content

Commit 3ca3e5c

Browse files
authored
tools: use breadth first search in vreduce (#24369)
1 parent 6d0eaa5 commit 3ca3e5c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎cmd/tools/vreduce.v‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ fn main() {
9494
}
9595

9696
// Return true if the command ran on the file produces the pattern
97-
fn string_reproduces(file string, pattern string, command string, path string, debug bool, timeout int) bool {
97+
fn string_reproduces(file_content string, pattern string, command string, dir string, debug bool, timeout int) bool {
9898
if !os.exists(tmp_folder) {
9999
os.mkdir(tmp_folder) or { panic(err) }
100100
}
101-
os.write_file(path, file) or { panic(err) }
101+
os.write_file(dir, file_content) or { panic(err) }
102102
mut output := ''
103103
if timeout == 0 {
104104
res := os.execute(command)
@@ -330,7 +330,7 @@ fn reduce_scope(content string, error_msg string, command string, do_fmt bool, p
330330
show_code_stats(code)
331331
} else { // if can remove it, no need to go though it's children
332332
for i in 0 .. item.children.len {
333-
stack << &item.children[i]
333+
stack.insert(0, &item.children[i]) // breadth first search
334334
}
335335
}
336336
}

0 commit comments

Comments
 (0)