Skip to content

Commit 8d10fc7

Browse files
committed
repr cache
1 parent 43a8b18 commit 8d10fc7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/rule_dsl.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ function _recurse_apply_ruleset_threaded(r::RuleSet, term, context; depth, threa
264264
Term{symtype(term)}(operation(term), args)
265265
end
266266

267+
const rule_repr = IdDict()
268+
267269
function (r::RuleSet)(term, context=EmptyCtx(); depth=typemax(Int), applyall::Bool=false, recurse::Bool=true,
268270
threaded::Bool=false, thread_subtree_cutoff::Int=100)
269271
rules = r.rules
@@ -286,7 +288,7 @@ function (r::RuleSet)(term, context=EmptyCtx(); depth=typemax(Int), applyall::B
286288
end
287289
for i in 1:length(rules)
288290
expr′ = try
289-
@timer(repr(rules[i]), rules[i](expr, context))
291+
@timer(Base.@get!(rule_repr, rules[i], repr(rules[i])), rules[i](expr, context))
290292
catch err
291293
throw(RuleRewriteError(rules[i], expr))
292294
end

0 commit comments

Comments
 (0)