premailer / css_parser

Ruby CSS Parser
Other
279 stars 110 forks source link

Use StringScanner instead of String#scan to improve block parsing performance #167

Closed leonid-shevtsov closed 3 months ago

leonid-shevtsov commented 3 months ago

This PR replaces scan in parse_block_into_rule_sets! with StringScanner - a more performant API for tokenizing strings.

Tenderlove had a post last year about this.

On our benchmarks this shows a 18% improvement in performance measured for overall add_block!. The code has been in production for around 3 years now, unfortunately making changes public takes additional effort.

Pre-Merge Checklist