askama/askama_escape
René Kijewski 6daf343e8b Escape HTML faster
Escaped HTML characters vary in length. So, in order to select the
correct replacement two variables need to be loaded: The pointer to the
new substring and its length. Because of this the generated code is less
dense than it could be.

With this PR instead of selecting the appropriate `&str`, an `&&str` is
selected. The former consumes two words while the latter consumes only
one. Intuitively one might assume that the double dereference makes the
code slower, but the optimized lookup seems to be so much faster, so
that the change is worth its weight.

Comparing the result of `cargo bench` (best out of three runs for both):

```text
Old:  [4.3592 µs 4.3675 µs 4.3764 µs]
New:  [3.8691 µs 3.8766 µs 3.8860 µs]
Diff: [-11.24 %  -11.24 %  -12.21 % ]
```
2023-03-30 14:49:15 +02:00
..
2021-07-01 16:10:43 +02:00
2023-03-30 14:49:15 +02:00
2020-06-30 13:35:53 +02:00

askama_escape: escaping utilities for the Askama templating engine

Documentation Latest version Build Status Chat

This crate contains helper code for HTML escaping used by the Askama templating engine.