tweag / ormolu

A formatter for Haskell source code
https://ormolu-live.tweag.io
Other
956 stars 83 forks source link

De`String`ify #963

Closed amesgen closed 1 year ago

amesgen commented 1 year ago

Retroactive cause: Closes #972

When thinking about e.g. #959, it always bugged me that we use Strings in so many places. This PR removes the two primary occurences:

Apart from better type safety, we get speedups:

For fixity parsing overhead (see #959 for the setup, ormolu is 0.5.2.0 here):

Command Mean [ms] Min [ms] Max [ms] Relative
ormolu --no-cabal test-a.hs 1.5 ± 0.4 0.9 4.5 1.00
result-nostrs/bin/ormolu --no-cabal test-a.hs 2.6 ± 0.7 1.7 7.2 1.69 ± 0.62
ormolu --no-cabal test-b.hs 37.1 ± 2.1 34.5 52.3 24.37 ± 6.46
result-nostrs/bin/ormolu --no-cabal test-b.hs 20.1 ± 1.1 18.6 22.6 13.23 ± 3.50
ormolu --no-cabal test-c.hs 84.8 ± 3.2 82.0 96.4 55.71 ± 14.57
result-nostrs/bin/ormolu --no-cabal test-c.hs 60.2 ± 3.2 57.0 75.0 39.58 ± 10.46

Test suite execution time also dropped by 10% from 940ms to 840 ms.

mrkkrp commented 1 year ago

Note to self: return to this once #940 is merged.