Commit e7c1e74
committed
Fix #642 Bad performance/memory leak for long list literals
A one-character fix that speeds up the formatting of long literals
and drastically reduces memory usage.
A very simple example is
```elm
module Small exposing (x)
x =
[ 1, 2, 3
, 4]
```
But with a list literal of many thousands of elements. The newline
forces all elements to get their own line. This is implemented as a
fold, but in practice this would often perform
```
longList ++ shortList
```
By reversing the fold (from `foldl` to `foldr`) that turns into
```
shortList ++ longList
```
Which requires less traversals and memory.1 parent 1fa616f commit e7c1e74
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| |||
0 commit comments