• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cheeriojs / cheerio / 30450340954 / 1
100%
main: 100%

Build:
Build:
LAST BUILD BRANCH: chore/eslint-config-0.5
DEFAULT BRANCH: main
Ran 29 Jul 2026 12:08PM UTC
Files 16
Run time 0s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

29 Jul 2026 12:08PM UTC coverage: 99.562% (+0.004%) from 99.558%
30450340954.1

Pull #5380

github

fb55
perf(traversing): keep closest() dedup and map() accumulation linear

Two quadratic accumulation paths, found while auditing for asymmetric
cost.

`closest()` guarded against duplicates with `set.includes(elem)`, a scan
of a growing array. When each element resolves to a distinct ancestor the
result set grows to n and the scan work is n(n-1)/2. Keep the array scan
for the small result sets `closest` normally yields and switch to a Set
once the set passes 100 entries, so ordering and dedup semantics are
unchanged while the pathological case stays linear. A Set from the start
was measured 4-7% slower on ordinary collections, since the allocation
and hashing are paid on every call regardless of result size.

`map()` accumulated with `elems = elems.concat(val)`, rebuilding the
whole array each iteration. Push instead, spreading array return values
with a loop to keep `concat`'s one-level flatten, including its treatment
of `null`/`undefined` members.

closest() over 64k distinct matches: 467ms -> 13.6ms. map() over 40k
elements: 2971ms -> 0.94ms. Ordinary 50-element calls: closest +0.2%
(noise), map ~12x faster. Both regression tests assert operation counts
rather than timings.
Pull Request #5380: perf(traversing): keep closest() dedup and map() accumulation linear

265 of 265 branches covered (100.0%)

Branch coverage included in aggregate %.

872 of 877 relevant lines covered (99.43%)

378.8 hits per line

Source Files on job 30450340954.1
  • Tree
  • List 16
  • Changed 2
  • Source Changed 2
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 30450340954
  • 208682b5 on github
  • Prev Job for on perf/closest-map-linear (#30449701432.1)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc