[commit: packages/containers] develop-0.6, develop-0.6-questionable, master, zip-devel: Make index middle-lazy (aedfe3f)

git at git.haskell.org git at git.haskell.org
Fri Jan 23 22:40:15 UTC 2015


Repository : ssh://git@git.haskell.org/containers

On branches: develop-0.6,develop-0.6-questionable,master,zip-devel
Link       : http://git.haskell.org/packages/containers.git/commitdiff/aedfe3f327f781484ec6fb4718156919791c4979

>---------------------------------------------------------------

commit aedfe3f327f781484ec6fb4718156919791c4979
Author: David Feuer <David.Feuer at gmail.com>
Date:   Sun Nov 23 15:36:39 2014 -0500

    Make index middle-lazy
    
    `index` should not descend the finger tree spine unless it needs
    to.


>---------------------------------------------------------------

aedfe3f327f781484ec6fb4718156919791c4979
 Data/Sequence.hs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Data/Sequence.hs b/Data/Sequence.hs
index 4e37dbf..511cad9 100644
--- a/Data/Sequence.hs
+++ b/Data/Sequence.hs
@@ -1159,14 +1159,14 @@ data Place a = Place {-# UNPACK #-} !Int a
 lookupTree :: Sized a => Int -> FingerTree a -> Place a
 lookupTree _ Empty = error "lookupTree of empty tree"
 lookupTree i (Single x) = Place i x
-lookupTree i (Deep _ pr m sf)
+lookupTree i (Deep totalSize pr m sf)
   | i < spr     =  lookupDigit i pr
   | i < spm     =  case lookupTree (i - spr) m of
                    Place i' xs -> lookupNode i' xs
   | otherwise   =  lookupDigit (i - spm) sf
   where
     spr     = size pr
-    spm     = spr + size m
+    spm     = totalSize - size sf
 
 {-# SPECIALIZE lookupNode :: Int -> Node (Elem a) -> Place (Elem a) #-}
 {-# SPECIALIZE lookupNode :: Int -> Node (Node a) -> Place (Node a) #-}



More information about the ghc-commits mailing list