robb / Swim

A DSL for writing HTML in Swift
310 stars 9 forks source link

Scan String before escaping #30

Closed robb closed 3 years ago

robb commented 3 years ago

This adds the same approach that CF uses by scanning the String for offending characters first before committing to an allocation.

Before (209e8a9):

name               time          std        iterations
------------------------------------------------------
Build a basic page 128375.000 ns ±   3.61 %       9928

After:

name               time          std        iterations
------------------------------------------------------
Build a basic page 102250.000 ns ±   1.52 %      12034