Skip to content

Commit 1596d6b

Browse files
committed
compiler: Use counter
1 parent 7d618d6 commit 1596d6b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

devito/passes/clusters/cse.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from collections import defaultdict
1+
from collections import defaultdict, Counter
22
from functools import cached_property, singledispatch
33

44
import numpy as np
@@ -230,13 +230,14 @@ def _compact(exprs, exclude):
230230

231231
# Find all the CTemps in expression right-hand-sides without removing duplicates
232232
ctemps = retrieve_ctemps([e.rhs for e in exprs])
233+
ctemp_count = Counter(ctemps)
233234

234235
# If there are ctemps in the expressions, then add any to the mapper which only
235236
# appear once
236237
# TODO: Double check this is exactly the prior behaviour
237238
if ctemps:
238239
mapper.update({e.lhs: e.rhs for e in candidates
239-
if ctemps.count(e.lhs) == 1})
240+
if ctemp_count[e.lhs] == 1})
240241

241242
processed = []
242243
for e in exprs:

0 commit comments

Comments
 (0)