This PR replaces the escape function with an implementation optimised specifically for each target:
There's a highly optimised version for escaping on the Erlang target, it's performance is now on par with what Phoenix.HTML does when producing an escaped String.
For the JavaScript one the implementation is generic enough that it could also work on the Erlang target but it's a bit less efficient so I decided to still split the two implementations
I moved the implementations to another internal module because I ended up using @target quite a bit and didn't really like having it inside the VDOM module (but that's just vibes, if you want I can put everything back there)
Also it would be nice if we had a "real" page to render and see the actual difference in performance between the two implementations when used in a realistic scenario, it's always nice to boast about perf improvements 😎
This PR replaces the
escape
function with an implementation optimised specifically for each target:Phoenix.HTML
does when producing an escaped String.@target
quite a bit and didn't really like having it inside the VDOM module (but that's just vibes, if you want I can put everything back there)Also it would be nice if we had a "real" page to render and see the actual difference in performance between the two implementations when used in a realistic scenario, it's always nice to boast about perf improvements 😎