Skip to content

Commit 810acee

Browse files
committed
Rewrote LookupRules using Dictionary.condExchange
1 parent fecfd00 commit 810acee

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

lib/compiler/PEG.oz

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,9 @@ define
142142
TemporaryRules = {Dictionary.new}
143143

144144
fun {LookupRule Name}
145-
if {Dictionary.member TemporaryRules Name} then
146-
{Dictionary.get TemporaryRules Name}
147-
else
148-
local NewRule in
149-
{Dictionary.put TemporaryRules Name NewRule}
150-
NewRule
151-
end
145+
local Result in
146+
{Dictionary.condExchange TemporaryRules Name _ Result Result}
147+
Result
152148
end
153149
end
154150

0 commit comments

Comments
 (0)