robb / Swim

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

Make attribute values `AnyHashable` #28

Open robb opened 3 years ago

robb commented 3 years ago

This makes it easier to use nodes with custom attribute values without having to convert to and from String.

Unwrapping the base value and checking the type manually has overhead but it seems bearable.

Before (ebe61c2):

name               time          std        iterations
------------------------------------------------------
Build a basic page 211250.000 ns ±   2.32 %       6397

After:

name               time          std        iterations
------------------------------------------------------
Build a basic page 234208.000 ns ±   2.29 %       5850

(Not checking against String or TextOutputStreamable performs worse still).