ClojureScript

Fix count for non-counted collections, remove ICounted from Cons

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code

Description

This caused TwitterBuzz breakage reported by leimy in #clojure: http://clojure-log.n01se.net/date/2012-05-01.html#21:36

Patch created on top of CLJS-228, but should apply cleanly to master.

From the commit message:

Since default no longer gets extended to ICounted, the original
implementation of cljs.core/count no longer works on LazySeq
instances.

This patch takes the approach of checking whether the given collection
is counted and either calling -count or a linear traversal
helper (which rolls over to -count as soon as possible).

The implementation of ICounted on Cons is now unnecessary and has been
removed, so that things for which counted? returns true really do
provide constant-time count.

Activity

Hide
Michał Marczyk added a comment -

The actual patch file this time.

Show
Michał Marczyk added a comment - The actual patch file this time.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: