Skip to content

Commit b6ed146

Browse files
authored
Refactor the updateOrSnocWithKey otherwise case
1 parent 6ebe947 commit b6ed146

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Data/HashMap/Base.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,9 +1948,12 @@ updateOrSnocWithKey f k0 v0 ary0 = go k0 v0 ary0 0 (A.length ary0)
19481948
A.copy ary 0 mary 0 n
19491949
A.write mary n (L k v)
19501950
return mary
1951-
| otherwise = case A.index ary i of
1952-
(L kx y) | k == kx, (# v2 #) <- f k v y -> A.update ary i (L k v2)
1953-
| otherwise -> go k v ary (i+1) n
1951+
| L kx y <- A.index ary i
1952+
, k == kx
1953+
, (# v2 #) <- f k v y
1954+
= A.update ary i (L k v2)
1955+
| otherwise
1956+
= go k v ary (i+1) n
19541957
{-# INLINABLE updateOrSnocWithKey #-}
19551958

19561959
updateOrConcatWith :: Eq k => (v -> v -> v) -> A.Array (Leaf k v) -> A.Array (Leaf k v) -> A.Array (Leaf k v)

0 commit comments

Comments
 (0)