Details
Assignee
UnassignedUnassignedReporter
Jozef WagnerJozef WagnerLabels
Approval
TriagedPatch
CodePriority
Minor
Details
Details
Assignee
Unassigned
UnassignedReporter
Jozef Wagner
Jozef WagnerLabels
Approval
Triaged
Patch
Code
Priority
Created March 9, 2014 at 3:10 PM
Updated June 23, 2015 at 8:15 PM
Even if underlying seq contains a cached hash, LazySeq computes it every time.
user=> *clojure-version* {:major 1, :minor 7, :incremental 0, :qualifier "master", :interim true} user=> (def a (range 100000)) #'user/a user=> (time (hash a)) "Elapsed time: 21.812 msecs" 375952610 user=> (time (hash a)) ;; hash is cached "Elapsed time: 0.036 msecs" 375952610 user=> (def b (seq a)) #'user/b user=> (time (hash b)) "Elapsed time: 0.042 msecs" ;; uses cached hash 375952610 user=> (def c (lazy-seq b)) #'user/c user=> (time (hash c)) ;; SHOULD use underlying hash "Elapsed time: 27.758 msecs" 375952610 user=> (time (hash c)) ;; SHOULD use underlying hash "Elapsed time: 17.846 msecs" 375952610
Approach: If seq produced by LazySeq implementing IHashEq, use it to calculate the hasheq().
Patch: clj-1373.diff