tags: speedup: replace n^2 nub with n log n nubSort
This commit is contained in:
parent
07c4b3e0ab
commit
8cde342432
@ -7,7 +7,7 @@ module Hledger.Cli.Commands.Tags (
|
|||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
import Data.List
|
import Data.List.Extra (nubSort)
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Data.Text.IO as T
|
import qualified Data.Text.IO as T
|
||||||
import Safe
|
import Safe
|
||||||
@ -33,7 +33,7 @@ tags CliOpts{rawopts_=rawopts,reportopts_=ropts} j = do
|
|||||||
q = queryFromOpts d $ ropts{query_ = unwords queryargs}
|
q = queryFromOpts d $ ropts{query_ = unwords queryargs}
|
||||||
txns = filter (q `matchesTransaction`) $ jtxns $ journalSelectingAmountFromOpts ropts j
|
txns = filter (q `matchesTransaction`) $ jtxns $ journalSelectingAmountFromOpts ropts j
|
||||||
tagsorvalues =
|
tagsorvalues =
|
||||||
nub $ sort $
|
nubSort $
|
||||||
[if values then v else t
|
[if values then v else t
|
||||||
| (t,v) <- concatMap transactionAllTags txns
|
| (t,v) <- concatMap transactionAllTags txns
|
||||||
, maybe True (`regexMatchesCI` T.unpack t) mtagpat
|
, maybe True (`regexMatchesCI` T.unpack t) mtagpat
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user