visionmedia/css-parse — pull request #55 by brettstimmerman (2013-10-22 23:26:01+00:00)
Title: Performance improvements to atrule() and trim() fns

I found a couple tiny (code-wise) perf tweaks with a big impact today.

Before this change, atrule() was a cascade of potentially failing RegExps.
This change introduces a short-circuit that bypasses the RegExps if the
next character is not an @. `make bench` shows a 20-25% improvement in
op/s.

Also before this change, trim() used a custom RegExp to remove whitespace.
This change replaces the RegExp with native String.prototype.trim.
`make bench` shows a 10-12% improvement in op/s.

With both changes, `make bench` shows a combined 45-55% improvement.

Benchmarks were run 5 times and the results averaged.