Skip to content

Commit 2994e16

Browse files
authored
Merge pull request #135 from JuliaSymbolics/s/hash-speed
speed up hash on Term
2 parents fac36de + c885dec commit 2994e16

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/types.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,11 @@ operation(x::Term) = x.f
278278

279279
arguments(x::Term) = x.arguments
280280

281+
## This is much faster than hash of an array of Any
282+
hashvec(xs, z) = foldr(hash, xs, init=z)
283+
281284
function Base.hash(t::Term{T}, salt::UInt) where {T}
282-
hash(arguments(t), hash(operation(t), hash(T, salt)))
285+
hashvec(arguments(t), hash(operation(t), hash(T, salt)))
283286
end
284287

285288
function Base.isequal(t1::Term, t2::Term)

0 commit comments

Comments
 (0)