We're updating the issue view to help you get more done. 

Add fast path in seq comparison for structurally sharing seqs

Description

Currently comparing two non identical seqs requires iterating through both seqs comparing value by value, ignoring the possibility of seq `a` and `b` having the same (pointer-equal) rest.

The proposed patch adds a pointer equality check on the seq tails that can make the equality short-circuit if the test returns true, which is helpful when comparing large (or possibly infinite) seqs that share a common subseq.

After this patch, comparisons like

1 (let [x (range)] (= x (cons 0 (rest x))))

which currently don't terminate, return true in constant time.

Patch: CLJ-1679-v3.patch

Environment

None

Status

Assignee

Unassigned

Reporter

Nicola Mometto

Approval

None

Patch

Code and Test

Priority

Major