| stripAnsi is called many times during rendering (by strWidth), so should be fast. It was originally a regex replacement, and more recently a custom parser. The parser was slower, particularly the one in 1.19.1. See #1350, and this rough test: time118ish = timeIt $ print $ length $ concat $ map (fromRight undefined . regexReplace (toRegex' "\ESC\\[([0-9]+;)*([0-9]+)?[ABCDHJKfmsu]") "") testdata time119 = timeparser (many (takeWhile1P Nothing (/='\ESC') <|> "" <$ ansi)) time1191 = timeparser (many ("" <$ try ansi <|> pure <$> anySingle)) timeparser p = timeIt $ print $ length $ concat $ map (concat . fromJust . parseMaybe p) testdata testdata = concat $ replicate 10000 [ "2008-01-01 income assets🏦checking $1 $1" , "2008-06-01 gift assets🏦checking $1 $2" , "2008-06-02 save assets🏦saving $1 $3" , " assets🏦checking ..m$-1\ESC[m\ESC[m $2" , "2008-06-03 eat & shop assets:cash ..m$-2\ESC[m\ESC[m 0" , "2008-12-31 pay off assets🏦checking ..m$-1\ESC[m\ESC[m ..m$-1\ESC[m\ESC[m" ] ghci> time118ish 4560000 CPU time: 0.17s ghci> time119 4560000 CPU time: 0.91s ghci> time1191 4560000 CPU time: 2.76s Possibly a more careful parser could beat regexReplace. Note the latter does memoisation, which could be faster and/or could also use more resident memory in some situations. Ideally we would calculate all widths before adding ANSI colour codes, so we wouldn't have to wastefully strip them. | ||
|---|---|---|
| .. | ||
| Hledger | ||
| other/ledger-parse | ||
| test | ||
| Text | ||
| .ghci | ||
| .version | ||
| CHANGES.md | ||
| defs.m4 | ||
| hledger_csv.5 | ||
| hledger_csv.info | ||
| hledger_csv.m4.md | ||
| hledger_csv.txt | ||
| hledger_journal.5 | ||
| hledger_journal.info | ||
| hledger_journal.m4.md | ||
| hledger_journal.txt | ||
| hledger_timeclock.5 | ||
| hledger_timeclock.info | ||
| hledger_timeclock.m4.md | ||
| hledger_timeclock.txt | ||
| hledger_timedot.5 | ||
| hledger_timedot.info | ||
| hledger_timedot.m4.md | ||
| hledger_timedot.txt | ||
| hledger-lib.cabal | ||
| Hledger.hs | ||
| LICENSE | ||
| package.yaml | ||
| README.md | ||
| Setup.hs | ||
hledger-lib
A reusable library containing hledger’s core functionality. This is used by most hledger* packages so that they support the same common file formats, command line options, reports etc.
See also: the project README and home page.