mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-11-29 21:46:11 +03:00
renderBox: avoid unnecessary use of dlist
`renderBox` uses dlist to grow the result list while doing a render traversal. An ordinary fmap'd list construction suffices and offers a very small but measurable performance boost. Furthermore this is the only place the *dlist* library was used so *brick* no longer depends on it.
This commit is contained in:
parent
3417a47413
commit
2b97d32db5
@ -123,7 +123,6 @@ library
|
||||
bimap >= 0.5 && < 0.6,
|
||||
data-clist >= 0.1,
|
||||
directory >= 1.2.5.0,
|
||||
dlist,
|
||||
exceptions >= 0.10.0,
|
||||
filepath,
|
||||
containers >= 0.5.7,
|
||||
|
@ -126,7 +126,6 @@ import Control.Monad.State.Strict
|
||||
import Control.Monad.Reader
|
||||
import qualified Data.Foldable as F
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.DList as DL
|
||||
import qualified Data.Map as M
|
||||
import qualified Data.Set as S
|
||||
import qualified Data.IMap as I
|
||||
@ -642,15 +641,15 @@ renderBox br ws =
|
||||
let availPrimary = c^.(contextPrimary br)
|
||||
availSecondary = c^.(contextSecondary br)
|
||||
|
||||
renderHis _ prev [] = return $ DL.toList prev
|
||||
renderHis remainingPrimary prev ((i, prim):rest) = do
|
||||
renderHis _ [] = pure []
|
||||
renderHis remainingPrimary ((i, prim):rest) = do
|
||||
result <- render $ limitPrimary br remainingPrimary
|
||||
$ limitSecondary br availSecondary
|
||||
$ cropToContext prim
|
||||
renderHis (remainingPrimary - (result^.imageL.(to $ imagePrimary br)))
|
||||
(DL.snoc prev (i, result)) rest
|
||||
let newRem = remainingPrimary - (result^.imageL.(to $ imagePrimary br))
|
||||
((i, result) :) <$> renderHis newRem rest
|
||||
|
||||
renderedHis <- renderHis availPrimary DL.empty his
|
||||
renderedHis <- renderHis availPrimary his
|
||||
|
||||
renderedLows <- case lows of
|
||||
[] -> return []
|
||||
|
Loading…
Reference in New Issue
Block a user