@@ -223,22 +223,28 @@ Base.nameof(s::BasicSymbolic) = issym(s) ? s.name : error("None Sym BasicSymboli
223223
224224# # This is much faster than hash of an array of Any
225225hashvec (xs, z) = foldr (hash, xs, init= z)
226+
227+ const SYM_SALT = 0x4de7d7c66d41da43 % UInt
228+ const ADD_SALT = 0xaddaddaddaddadda % UInt
229+ const SUB_SALT = 0xaaaaaaaaaaaaaaaa % UInt
230+ const DIV_SALT = 0x334b218e73bbba53 % UInt
231+ const POW_SALT = 0x2b55b97a6efb080c % UInt
226232function Base. hash (s:: BasicSymbolic , salt:: UInt )
227233 E = exprtype (s)
228234 if E === SYM
229- hash (nameof (s), salt ⊻ 0x4de7d7c66d41da43 )
235+ hash (nameof (s), salt ⊻ SYM_SALT )
230236 elseif E === ADD || E === MUL
231- ! iszero (salt) && return hash (hash (s, zero (UInt64 )), salt)
237+ ! iszero (salt) && return hash (hash (s, zero (UInt )), salt)
232238 h = s. hash[]
233239 ! iszero (h) && return h
234- hashoffset = isadd (s) ? 0xaddaddaddaddadda : 0xaaaaaaaaaaaaaaaa
235- h′= hash (hashoffset, hash (s. coeff, hash (s. dict, salt)))
240+ hashoffset = isadd (s) ? ADD_SALT : SUB_SALT
241+ h′ = hash (hashoffset, hash (s. coeff, hash (s. dict, salt)))
236242 s. hash[] = h′
237243 return h′
238244 elseif E === DIV
239- return hash (s. num, hash (s. den, salt ⊻ 0x334b218e73bbba53 ))
245+ return hash (s. num, hash (s. den, salt ⊻ DIV_SALT ))
240246 elseif E === POW
241- hash (s. exp, hash (s. base, salt ⊻ 0x2b55b97a6efb080c ))
247+ hash (s. exp, hash (s. base, salt ⊻ POW_SALT ))
242248 elseif E === TERM
243249 ! iszero (salt) && return hash (hash (s, zero (UInt)), salt)
244250 h = s. hash[]
0 commit comments