Files
chasquid/internal/normalize/normalize.go
Alberto Bertogli 41bb7b6f5e normalize: Improve ToCRLF/StringToCRLF performance
The ToCRLF/StringToCRLF functions are not very performance critical, but
we call it for each mail, and the current implementation is very
inefficient (mainly because it goes one byte at a time).

This patch replaces it with a better implementation that goes line by line.

The new implementation of ToCRLF is ~40% faster, and StringToCRLF is ~60%
faster.

```
$ benchstat old.txt new.txt
goos: linux
goarch: amd64
pkg: blitiri.com.ar/go/chasquid/internal/normalize
cpu: 13th Gen Intel(R) Core(TM) i9-13900T
                │    old.txt    │               new.txt                │
                │    sec/op     │    sec/op     vs base                │
ToCRLF-32         162.96µ ±  6%   95.42µ ± 12%  -41.44% (p=0.000 n=10)
StringToCRLF-32   190.70µ ± 14%   76.51µ ±  6%  -59.88% (p=0.000 n=10)
geomean            176.3µ         85.44µ        -51.53%
```
2024-10-31 13:10:14 +00:00

3.8 KiB