Skip to content

Commit b59a83f

Browse files
authored
v.ast: use the p := unsafe{ &m[key] or { nil } } pattern in Scope.find_ptr/1 (part 1) (#25410)
1 parent b59b787 commit b59a83f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

vlib/v/ast/scope.v

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ pub fn (s &Scope) find_ptr(name string) &ScopeObject {
6565
return 0
6666
}
6767
for sc := unsafe { s }; true; sc = sc.parent {
68-
if name in sc.objects {
69-
return unsafe { &sc.objects[name] }
68+
pobj := unsafe { &sc.objects[name] or { nil } }
69+
if pobj != unsafe { nil } {
70+
return pobj
7071
}
7172
if sc.dont_lookup_parent() {
7273
break

0 commit comments

Comments
 (0)