mirror of
https://github.com/joshuaclayton/unused.git
synced 2024-09-11 04:45:28 +03:00
Parallelize search
Why? ==== Searching hundreds or thousands of tokens with ag can be slow; this introduces parallel processing of search so results are returned more quickly.
This commit is contained in:
parent
bbb178f7d5
commit
a8a9d250e3
@ -5,6 +5,7 @@ module Unused.CLI.ProgressIndicator
|
||||
, progressWithIndicator
|
||||
) where
|
||||
|
||||
import Control.Concurrent.ParallelIO
|
||||
import Unused.CLI.Util
|
||||
import Unused.CLI.ProgressIndicator.Types
|
||||
import Unused.CLI.ProgressIndicator.Internal
|
||||
@ -23,6 +24,6 @@ progressWithIndicator :: (a -> IO [b]) -> ProgressIndicator -> [a] -> IO [b]
|
||||
progressWithIndicator f i terms = do
|
||||
printPrefix i
|
||||
indicator <- start i $ length terms
|
||||
concat <$> sequence (ioOps indicator) <* stop indicator
|
||||
concat <$> parallel (ioOps indicator) <* stop indicator <* stopGlobalPool
|
||||
where
|
||||
ioOps i' = map (\t -> f t <* increment i') terms
|
||||
|
@ -42,6 +42,7 @@ library
|
||||
, terminal-progress-bar
|
||||
, ansi-terminal
|
||||
, unix
|
||||
, parallel-io
|
||||
ghc-options: -Wall -Werror -O2
|
||||
default-language: Haskell2010
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user