Permalink
Browse files

unionArrayBy: code cleans up

  • Loading branch information...
1 parent 5df8a61 commit d67d1f0e947837ac7e32de138945c4e0a8f59b01 @bjin bjin committed Mar 26, 2012
Showing with 7 additions and 6 deletions.
  1. +7 −6 Data/HashMap/Base.hs
View
13 Data/HashMap/Base.hs
@@ -614,16 +614,17 @@ unionArrayBy f b1 b2 ary1 ary2 = A.run $ do
mary <- A.new_ (popCount b')
-- iterate over nonzero bits of b1 .|. b2
-- it would be nice if we could shift m by more than 1 each time
- let go !i !i1 !i2 !m
- | m > b' = return ()
- | b' .&. m == 0 = go i i1 i2 (m `unsafeShiftL` 1)
- | b1 .&. b2 .&. m /= 0 = do
+ let ba = b1 .&. b2
+ go !i !i1 !i2 !m
+ | m > b' = return ()
+ | b' .&. m == 0 = go i i1 i2 (m `unsafeShiftL` 1)
+ | ba .&. m /= 0 = do
A.write mary i $! f (A.index ary1 i1) (A.index ary2 i2)
go (i+1) (i1+1) (i2+1) (m `unsafeShiftL` 1)
- | b1 .&. m /= 0 = do
+ | b1 .&. m /= 0 = do
A.write mary i =<< A.index_ ary1 i1
go (i+1) (i1+1) (i2 ) (m `unsafeShiftL` 1)
- | otherwise = do
+ | otherwise = do
A.write mary i =<< A.index_ ary2 i2
go (i+1) (i1 ) (i2+1) (m `unsafeShiftL` 1)
go 0 0 0 1

0 comments on commit d67d1f0

Please sign in to comment.