d3 / d3-color

Color spaces! RGB, HSL, Cubehelix, CIELAB, and more.
https://d3js.org/d3-color
ISC License
400 stars 91 forks source link

avoid catastrophic backtracking #99

Closed mbostock closed 2 years ago

mbostock commented 2 years ago

Fixes #97. Supersedes #89. No change in behavior; just a new implementation that uses a tokenizer and a positive lookahead to mimic an atomic group.

Demo: https://observablehq.com/d/ae672b8cd8dacfab

On my computer, the input with 200,000 repeating ones took 57 seconds with the current version of d3-color, and <1ms with this new approach.

mbostock commented 2 years ago

Superseded by #100. (This implementation is fine, too, but I think I’d prefer to minimize churn with the other approach.)