From f89f3dcee10dbd2f6a515f332f80cf1a764ff7c0 Mon Sep 17 00:00:00 2001 From: Oleksii Divak <37468398+BurningWitness@users.noreply.github.com> Date: Sun, 19 May 2024 19:43:00 +0300 Subject: [PATCH] Performance adjustments (#3) * Tightening down radix tree loop arguments. * Removing CircleCI configuration file, cutting down the Github Actions one, adding GHC 9.10 to the CI matrix. * v1.0.0.1 bump. --- .circleci/config.yml | 71 --------------- .github/workflows/ci.yaml | 32 ++----- radix-tree.cabal | 2 +- src/Data/RadixNTree/Word8/Lazy.hs | 108 +++++++++++------------ src/Data/RadixNTree/Word8/Strict.hs | 132 ++++++++++++++-------------- 5 files changed, 129 insertions(+), 216 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 1f6fd1b..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,71 +0,0 @@ -version: 2.1 - -jobs: - build: - machine: - image: ubuntu-2004:current - resource_class: medium - parameters: - cabal: - type: string - ghc: - type: string - steps: - - checkout - - restore_cache: - name: Restore - key: linux-<< parameters.ghc >>-{{ checksum "radix-tree.cabal" }} - - run: - name: Install GHC - command: | - curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_MINIMAL=1 sh - - PATH=$HOME/.ghcup/bin:$PATH - echo 'export PATH=$HOME/.ghcup/bin:$PATH' >> $BASH_ENV - - ghcup install cabal << parameters.cabal >> - ghcup set cabal << parameters.cabal >> - - ghcup install ghc << parameters.ghc >> - ghcup set ghc << parameters.ghc >> - - - run: - name: Update Dependencies - command: cabal new-update - - run: - name: Build - command: cabal new-build --enable-tests - - save_cache: - name: Cache - key: linux-<< parameters.ghc >>-{{ checksum "radix-tree.cabal" }} - paths: - - "/root/.cabal" - - "dist-newstyle" - - run: - name: Test - command: cabal new-test --test-show-details=streaming - - - -workflows: - workflow: - jobs: - - build: - name: linux-9.0.2 - cabal: 3.6.2.0 - ghc: 9.0.2 - - - build: - name: linux-9.2.7 - cabal: 3.6.2.0 - ghc: 9.2.7 - - - build: - name: linux-9.4.8 - cabal: 3.6.2.0 - ghc: 9.4.8 - - - build: - name: linux-9.6.4 - cabal: 3.6.2.0 - ghc: 9.6.4 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 17ca19f..707e691 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,6 +12,11 @@ jobs: name: GHC ${{ matrix.ghc }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} + # https://github.com/orgs/community/discussions/57827 + if: github.event_name != 'pull_request' || + github.event.pull_request.head.repo.full_name != + github.event.pull_request.base.repo.full_name + strategy: fail-fast: false matrix: @@ -22,11 +27,7 @@ jobs: - "9.4" - "9.6" - "9.8" - include: - - os: macOS-latest - ghc: "9.8" - - os: windows-latest - ghc: "9.8" + - "9.10" steps: @@ -49,24 +50,7 @@ jobs: run: | cabal --version - - name: Unpack - run: | - cabal sdist --ignore-project --output-directory .. - cd .. - cabal get radix-tree-*.tar.gz - - name: Build & Test run: | - cd ../radix-tree-*/ - cabal build all --enable-tests - cabal test --enable-tests --test-show-details=direct all - - - name: Haddock - run: | - cd ../radix-tree-*/ - cabal haddock all - - - name: Cabal check - run: | - cd ../radix-tree-*/ - cabal check + cabal build --enable-tests + cabal test --enable-tests --test-show-details=direct properties diff --git a/radix-tree.cabal b/radix-tree.cabal index 14fb64e..db26971 100644 --- a/radix-tree.cabal +++ b/radix-tree.cabal @@ -1,5 +1,5 @@ name: radix-tree -version: 1.0.0.0 +version: 1.0.0.1 category: Data Structures synopsis: Radix trees diff --git a/src/Data/RadixNTree/Word8/Lazy.hs b/src/Data/RadixNTree/Word8/Lazy.hs index d01b0ef..579304c 100644 --- a/src/Data/RadixNTree/Word8/Lazy.hs +++ b/src/Data/RadixNTree/Word8/Lazy.hs @@ -945,7 +945,7 @@ lookup1 (Feed1 w feed) = feed $ \step -> lookup_ step w lookup_ :: (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Maybe a lookup_ step = go where - go w s t = + go !w !s t = case t of Bin p l r -> go w s $ if w < p @@ -954,7 +954,7 @@ lookup_ step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = let n' = n + 1 in if n' >= sizeofByteArray arr @@ -990,7 +990,7 @@ find1 d (Feed1 w feed) = feed $ \step -> find_ d step w find_ :: a -> (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> a find_ d step = go where - go w s t = + go !w !s t = case t of Bin p l r -> go w s $ if w < p @@ -999,7 +999,7 @@ find_ d step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = let n' = n + 1 in if n' >= sizeofByteArray arr @@ -1037,7 +1037,7 @@ member1 (Feed1 w feed) = feed $ \step -> member_ step w member_ :: (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Bool member_ step = go where - go w s t = + go !w !s t = case t of Bin p l r -> go w s $ if w < p @@ -1046,7 +1046,7 @@ member_ step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = let n' = n + 1 in if n' >= sizeofByteArray arr @@ -1082,7 +1082,7 @@ subtree1 (Feed1 w feed) = feed $ \step -> subtree_ step w subtree_ :: (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> RadixTree a subtree_ step = go where - go w s t = + go !w !s t = case t of Bin p l r -> go w s $ if w < p @@ -1091,7 +1091,7 @@ subtree_ step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = if n + 1 >= sizeofByteArray arr then case step z of @@ -1124,7 +1124,7 @@ prefix1 (Feed1 w feed) = {-# INLINE prefix_ #-} prefix_ :: (x -> Step Word8 x) -> Word8 -> x -> RadixTree a -> Radix1Tree a -prefix_ step = \w z (RadixTree mx t) -> +prefix_ step = \ !w !z (RadixTree mx t) -> case mx of Nothing -> case t of @@ -1183,7 +1183,7 @@ move_ step = \w s (Cursor point mx dx) -> Seam -> go w s dx Plane i arr -> goarr arr mx dx w s i where - go w s t = + go !w !s t = case t of Bin p l r -> go w s $ if w < p then l @@ -1195,7 +1195,7 @@ move_ step = \w s (Cursor point mx dx) -> goarr arr mx dx = goarr_ where - goarr_ w s n + goarr_ w !s n | w == indexByteArray arr n = let !n' = n + 1 in case step s of @@ -1280,7 +1280,7 @@ lookupL_ f openness step = go Lin Nothing where getThis = f b arr `fmap'` mx - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1339,7 +1339,7 @@ lookupR_ f openness step = go Lin Nothing let !(# b', arr, a #) = unsafeLookupMinWithKey_ b t in Just $! f b' arr a - go b getR w s t = + go b getR !w !s t = case t of Bin p l r -> if w < p @@ -1360,7 +1360,7 @@ lookupR_ f openness step = go Lin Nothing Nil -> Nothing _ -> getMin (Snoc b arr) dx - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1410,7 +1410,7 @@ adjustL_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a adjustL_ f openness step = go where - go w s t = + go !w !s t = case t of Bin p l r -> if w < p @@ -1424,7 +1424,7 @@ adjustL_ f openness step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1473,7 +1473,7 @@ adjustLWithKey_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a adjustLWithKey_ f openness step = go Lin where - go b w s t = + go b !w !s t = case t of Bin p l r -> if w < p @@ -1487,7 +1487,7 @@ adjustLWithKey_ f openness step = go Lin Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1538,7 +1538,7 @@ adjustR_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a adjustR_ f openness step = go where - go w s t = + go !w !s t = case t of Bin p l r -> if w < p @@ -1552,7 +1552,7 @@ adjustR_ f openness step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1605,7 +1605,7 @@ adjustRWithKey_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a adjustRWithKey_ f openness step = go Lin where - go b w s t = + go b !w !s t = case t of Bin p l r -> if w < p @@ -1619,7 +1619,7 @@ adjustRWithKey_ f openness step = go Lin Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1667,7 +1667,7 @@ updateL_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a updateL_ f openness step = go where - go w s t = + go !w !s t = case t of Bin p l r -> if w < p @@ -1681,7 +1681,7 @@ updateL_ f openness step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1734,7 +1734,7 @@ updateLWithKey_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a updateLWithKey_ f openness step = go Lin where - go b w s t = + go b !w !s t = case t of Bin p l r -> if w < p @@ -1748,7 +1748,7 @@ updateLWithKey_ f openness step = go Lin Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1799,7 +1799,7 @@ updateR_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a updateR_ f openness step = go where - go w s t = + go !w !s t = case t of Bin p l r -> if w < p @@ -1813,7 +1813,7 @@ updateR_ f openness step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1868,7 +1868,7 @@ updateRWithKey_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a updateRWithKey_ f openness step = go Lin where - go b w s t = + go b !w !s t = case t of Bin p l r -> if w < p @@ -1882,7 +1882,7 @@ updateRWithKey_ f openness step = go Lin Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1929,7 +1929,7 @@ takeL1 openness (Feed1 w0 feed) = feed $ \step -> takeL_ openness step w0 takeL_ :: Openness -> (x -> Step Prefix x) -> Prefix -> x -> Radix1Tree a -> Radix1Tree a takeL_ openness step = go where - go w s t = + go !w !s t = case t of Bin p l r -> if w < p @@ -1943,7 +1943,7 @@ takeL_ openness step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1988,7 +1988,7 @@ takeR1 openness (Feed1 w0 feed) = feed $ \step -> takeR_ openness step w0 takeR_ :: Openness -> (x -> Step Prefix x) -> Prefix -> x -> Radix1Tree a -> Radix1Tree a takeR_ openness step = go where - go w s t = + go !w !s t = case t of Bin p l r -> if w < p @@ -2002,7 +2002,7 @@ takeR_ openness step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -3730,7 +3730,7 @@ insert1 (Feed1 w feed) a = insert_ :: a -> (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Radix1Tree a insert_ a step = go where - go w s t = + go !w !s t = case t of Bin p l r | beyond p w -> join @@ -3742,7 +3742,7 @@ insert_ a step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = if n + 1 >= sizeofByteArray arr then case step z of @@ -3794,7 +3794,7 @@ insertWith_ :: (a -> a) -> a -> (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Radix1Tree a insertWith_ f a step = go where - go w s t = + go !w !s t = case t of Bin p l r | beyond p w -> join @@ -3806,7 +3806,7 @@ insertWith_ f a step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = if n + 1 >= sizeofByteArray arr then case step z of @@ -3856,7 +3856,7 @@ adjust1 f (Feed1 w feed) = adjust_ :: (a -> a) -> (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Radix1Tree a adjust_ f step = go where - go w s t = + go !w !s t = case t of Bin p l r | beyond p w -> t @@ -3865,7 +3865,7 @@ adjust_ f step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = if n + 1 >= sizeofByteArray arr then case step z of @@ -3899,7 +3899,7 @@ delete1 (Feed1 w feed) = delete_ :: (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Radix1Tree a delete_ step = go where - go w s t = + go !w !s t = case t of Bin p l r | beyond p w -> t @@ -3908,7 +3908,7 @@ delete_ step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = if n + 1 >= sizeofByteArray arr then case step z of @@ -3947,7 +3947,7 @@ prune1 openness (Feed1 w feed) = prune_ :: Openness -> (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Radix1Tree a prune_ openness step = go where - go w s t = + go !w !s t = case t of Bin p l r | beyond p w -> t @@ -3956,7 +3956,7 @@ prune_ openness step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = if n + 1 >= sizeofByteArray arr then case step z of @@ -3994,7 +3994,7 @@ update_ :: (a -> Maybe a) -> (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Radix1Tree a update_ f step = go where - go w s t = + go !w !s t = case t of Bin p l r | beyond p w -> t @@ -4003,7 +4003,7 @@ update_ f step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = if n + 1 >= sizeofByteArray arr then case step z of @@ -4039,7 +4039,7 @@ alter_ -> (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Radix1Tree a alter_ f step = go where - go w s t = + go !w !s t = case t of Bin p l r | beyond p w -> case f Nothing of @@ -4053,7 +4053,7 @@ alter_ f step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = if n + 1 >= sizeofByteArray arr then case step z of @@ -4110,7 +4110,7 @@ shape_ -> (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Radix1Tree a shape_ f step = go where - go w s t = + go !w !s t = case t of Bin p l r | beyond p w -> let !(RadixTree my dy) = f (RadixTree Nothing Nil) @@ -4125,7 +4125,7 @@ shape_ f step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = let n' = n + 1 in if n' >= sizeofByteArray arr @@ -4194,7 +4194,7 @@ splitL_ -> Word8 -> x -> Radix1Tree a -> (# Radix1Tree a, Radix1Tree a #) splitL_ openness step = go where - go w s t = + go !w !s t = case t of Bin p l r -> if w < p @@ -4212,7 +4212,7 @@ splitL_ openness step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -4266,7 +4266,7 @@ splitLookup_ -> Word8 -> x -> Radix1Tree a -> (# Radix1Tree a, Maybe a, Radix1Tree a #) splitLookup_ step = go where - go w s t = + go !w !s t = case t of Bin p l r -> if w < p @@ -4284,7 +4284,7 @@ splitLookup_ step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> diff --git a/src/Data/RadixNTree/Word8/Strict.hs b/src/Data/RadixNTree/Word8/Strict.hs index 2e8b263..4f0bfa8 100644 --- a/src/Data/RadixNTree/Word8/Strict.hs +++ b/src/Data/RadixNTree/Word8/Strict.hs @@ -1018,7 +1018,7 @@ lookup1 (Feed1 w feed) = feed $ \step -> lookup_ step w lookup_ :: (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Maybe a lookup_ step = go where - go w s t = + go !w !s t = case t of Bin p l r -> go w s $ if w < p @@ -1027,7 +1027,7 @@ lookup_ step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = let n' = n + 1 in if n' >= sizeofByteArray arr @@ -1063,7 +1063,7 @@ find1 d (Feed1 w feed) = feed $ \step -> find_ d step w find_ :: a -> (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> a find_ d step = go where - go w s t = + go !w !s t = case t of Bin p l r -> go w s $ if w < p @@ -1072,7 +1072,7 @@ find_ d step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = let n' = n + 1 in if n' >= sizeofByteArray arr @@ -1110,7 +1110,7 @@ member1 (Feed1 w feed) = feed $ \step -> member_ step w member_ :: (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Bool member_ step = go where - go w s t = + go !w !s t = case t of Bin p l r -> go w s $ if w < p @@ -1119,7 +1119,7 @@ member_ step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = let n' = n + 1 in if n' >= sizeofByteArray arr @@ -1155,7 +1155,7 @@ subtree1 (Feed1 w feed) = feed $ \step -> subtree_ step w subtree_ :: (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> RadixTree a subtree_ step = go where - go w s t = + go !w !s t = case t of Bin p l r -> go w s $ if w < p @@ -1164,7 +1164,7 @@ subtree_ step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = if n + 1 >= sizeofByteArray arr then case step z of @@ -1197,7 +1197,7 @@ prefix1 (Feed1 w feed) = {-# INLINE prefix_ #-} prefix_ :: (x -> Step Word8 x) -> Word8 -> x -> RadixTree a -> Radix1Tree a -prefix_ step = \w z (RadixTree mx t) -> +prefix_ step = \ !w !z (RadixTree mx t) -> case mx of Nothing -> case t of @@ -1256,7 +1256,7 @@ move_ step = \w s (Cursor point mx dx) -> Seam -> go w s dx Plane i arr -> goarr arr mx dx w s i where - go w s t = + go !w !s t = case t of Bin p l r -> go w s $ if w < p then l @@ -1268,7 +1268,7 @@ move_ step = \w s (Cursor point mx dx) -> goarr arr mx dx = goarr_ where - goarr_ w s n + goarr_ w !s n | w == indexByteArray arr n = let !n' = n + 1 in case step s of @@ -1353,7 +1353,7 @@ lookupL_ f openness step = go Lin Nothing where getThis = f b arr `fmap'` mx - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1412,7 +1412,7 @@ lookupR_ f openness step = go Lin Nothing let !(# b', arr, a #) = unsafeLookupMinWithKey_ b t in Just $! f b' arr a - go b getR w s t = + go b getR w !s t = case t of Bin p l r -> if w < p @@ -1433,7 +1433,7 @@ lookupR_ f openness step = go Lin Nothing Nil -> Nothing _ -> getMin (Snoc b arr) dx - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1483,7 +1483,7 @@ adjustL_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a adjustL_ f openness step = go where - go w s t = + go !w !s t = case t of Bin p l r -> if w < p @@ -1497,7 +1497,7 @@ adjustL_ f openness step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1547,7 +1547,7 @@ adjustL'_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a adjustL'_ f openness step = go where - go w s t = + go !w !s t = case t of Bin p l r -> if w < p @@ -1561,7 +1561,7 @@ adjustL'_ f openness step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1610,7 +1610,7 @@ adjustLWithKey_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a adjustLWithKey_ f openness step = go Lin where - go b w s t = + go b !w !s t = case t of Bin p l r -> if w < p @@ -1624,7 +1624,7 @@ adjustLWithKey_ f openness step = go Lin Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1679,7 +1679,7 @@ adjustLWithKey'_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a adjustLWithKey'_ f openness step = go Lin where - go b w s t = + go b !w !s t = case t of Bin p l r -> if w < p @@ -1693,7 +1693,7 @@ adjustLWithKey'_ f openness step = go Lin Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1744,7 +1744,7 @@ adjustR_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a adjustR_ f openness step = go where - go w s t = + go !w !s t = case t of Bin p l r -> if w < p @@ -1758,7 +1758,7 @@ adjustR_ f openness step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1808,7 +1808,7 @@ adjustR'_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a adjustR'_ f openness step = go where - go w s t = + go !w !s t = case t of Bin p l r -> if w < p @@ -1822,7 +1822,7 @@ adjustR'_ f openness step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1875,7 +1875,7 @@ adjustRWithKey_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a adjustRWithKey_ f openness step = go Lin where - go b w s t = + go b !w !s t = case t of Bin p l r -> if w < p @@ -1889,7 +1889,7 @@ adjustRWithKey_ f openness step = go Lin Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -1943,7 +1943,7 @@ adjustRWithKey'_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a adjustRWithKey'_ f openness step = go Lin where - go b w s t = + go b !w !s t = case t of Bin p l r -> if w < p @@ -1957,7 +1957,7 @@ adjustRWithKey'_ f openness step = go Lin Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -2005,7 +2005,7 @@ updateL_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a updateL_ f openness step = go where - go w s t = + go !w !s t = case t of Bin p l r -> if w < p @@ -2019,7 +2019,7 @@ updateL_ f openness step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -2072,7 +2072,7 @@ updateLWithKey_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a updateLWithKey_ f openness step = go Lin where - go b w s t = + go b !w !s t = case t of Bin p l r -> if w < p @@ -2086,7 +2086,7 @@ updateLWithKey_ f openness step = go Lin Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -2137,7 +2137,7 @@ updateR_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a updateR_ f openness step = go where - go w s t = + go !w !s t = case t of Bin p l r -> if w < p @@ -2151,7 +2151,7 @@ updateR_ f openness step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -2206,7 +2206,7 @@ updateRWithKey_ -> Word8 -> x -> Radix1Tree a -> Radix1Tree a updateRWithKey_ f openness step = go Lin where - go b w s t = + go b !w !s t = case t of Bin p l r -> if w < p @@ -2220,7 +2220,7 @@ updateRWithKey_ f openness step = go Lin Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -2267,7 +2267,7 @@ takeL1 openness (Feed1 w0 feed) = feed $ \step -> takeL_ openness step w0 takeL_ :: Openness -> (x -> Step Prefix x) -> Prefix -> x -> Radix1Tree a -> Radix1Tree a takeL_ openness step = go where - go w s t = + go !w !s t = case t of Bin p l r -> if w < p @@ -2281,7 +2281,7 @@ takeL_ openness step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -2326,7 +2326,7 @@ takeR1 openness (Feed1 w0 feed) = feed $ \step -> takeR_ openness step w0 takeR_ :: Openness -> (x -> Step Prefix x) -> Prefix -> x -> Radix1Tree a -> Radix1Tree a takeR_ openness step = go where - go w s t = + go !w !s t = case t of Bin p l r -> if w < p @@ -2340,7 +2340,7 @@ takeR_ openness step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -4055,7 +4055,7 @@ insert1 (Feed1 w feed) a = insert_ :: a -> (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Radix1Tree a insert_ a step = go where - go w s t = + go !w !s t = case t of Bin p l r | beyond p w -> join @@ -4067,7 +4067,7 @@ insert_ a step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = if n + 1 >= sizeofByteArray arr then case step z of @@ -4119,7 +4119,7 @@ insertWith_ :: (a -> a) -> a -> (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Radix1Tree a insertWith_ f a step = go where - go w s t = + go !w !s t = case t of Bin p l r | beyond p w -> join @@ -4131,7 +4131,7 @@ insertWith_ f a step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = if n + 1 >= sizeofByteArray arr then case step z of @@ -4187,7 +4187,7 @@ insertWith'_ :: (a -> a) -> a -> (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Radix1Tree a insertWith'_ f a step = go where - go w s t = + go !w !s t = case t of Bin p l r | beyond p w -> join @@ -4199,7 +4199,7 @@ insertWith'_ f a step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = if n + 1 >= sizeofByteArray arr then case step z of @@ -4249,7 +4249,7 @@ adjust1 f (Feed1 w feed) = adjust_ :: (a -> a) -> (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Radix1Tree a adjust_ f step = go where - go w s t = + go !w !s t = case t of Bin p l r | beyond p w -> t @@ -4258,7 +4258,7 @@ adjust_ f step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = if n + 1 >= sizeofByteArray arr then case step z of @@ -4292,7 +4292,7 @@ adjust1' f (Feed1 w feed) = adjust'_ :: (a -> a) -> (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Radix1Tree a adjust'_ f step = go where - go w s t = + go !w !s t = case t of Bin p l r | beyond p w -> t @@ -4301,7 +4301,7 @@ adjust'_ f step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = if n + 1 >= sizeofByteArray arr then case step z of @@ -4335,7 +4335,7 @@ delete1 (Feed1 w feed) = delete_ :: (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Radix1Tree a delete_ step = go where - go w s t = + go !w !s t = case t of Bin p l r | beyond p w -> t @@ -4344,7 +4344,7 @@ delete_ step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = if n + 1 >= sizeofByteArray arr then case step z of @@ -4383,7 +4383,7 @@ prune1 openness (Feed1 w feed) = prune_ :: Openness -> (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Radix1Tree a prune_ openness step = go where - go w s t = + go !w !s t = case t of Bin p l r | beyond p w -> t @@ -4392,7 +4392,7 @@ prune_ openness step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = if n + 1 >= sizeofByteArray arr then case step z of @@ -4430,7 +4430,7 @@ update_ :: (a -> Maybe a) -> (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Radix1Tree a update_ f step = go where - go w s t = + go !w !s t = case t of Bin p l r | beyond p w -> t @@ -4439,7 +4439,7 @@ update_ f step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = if n + 1 >= sizeofByteArray arr then case step z of @@ -4475,7 +4475,7 @@ alter_ -> (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Radix1Tree a alter_ f step = go where - go w s t = + go !w !s t = case t of Bin p l r | beyond p w -> case f Nothing of @@ -4489,7 +4489,7 @@ alter_ f step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = if n + 1 >= sizeofByteArray arr then case step z of @@ -4546,7 +4546,7 @@ shape_ -> (x -> Step Word8 x) -> Word8 -> x -> Radix1Tree a -> Radix1Tree a shape_ f step = go where - go w s t = + go !w !s t = case t of Bin p l r | beyond p w -> let !(RadixTree my dy) = f (RadixTree Nothing Nil) @@ -4561,7 +4561,7 @@ shape_ f step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n + goarr v !z n | v == indexByteArray arr n = let n' = n + 1 in if n' >= sizeofByteArray arr @@ -4636,7 +4636,7 @@ splitL_ -> Word8 -> x -> Radix1Tree a -> (# Radix1Tree a, Radix1Tree a #) splitL_ openness step = go where - go w s t = + go !w !s t = case t of Bin p l r -> if w < p @@ -4654,7 +4654,7 @@ splitL_ openness step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr -> @@ -4714,7 +4714,7 @@ splitLookup_ -> Word8 -> x -> Radix1Tree a -> (# Radix1Tree a, Maybe a, Radix1Tree a #) splitLookup_ step = go where - go w s t = + go !w !s t = case t of Bin p l r -> if w < p @@ -4732,7 +4732,7 @@ splitLookup_ step = go Tip arr mx dx -> goarr w s 0 where - goarr v z n = + goarr v !z n = let n' = n + 1 in case indexByteArray arr n `compare` v of EQ | n' >= sizeofByteArray arr ->