@@ -33,6 +33,7 @@ module Data.Text.Array
36#if defined(ASSERTS)
37#if defined(ASSERTS)
@@ -265,3 +266,31 @@ copyI dest i0 src j0 top
265 | i >= top = return ()
266 | i >= top = return ()
266 | otherwise = do unsafeWrite dest i (src `unsafeIndex` j)
267 | otherwise = do unsafeWrite dest i (src `unsafeIndex` j)
267 slow (i+1) (j+1)
268 slow (i+1) (j+1)
270+-- | Compare portions of two arrays for equality. No bounds checking
272+equal :: Array -- ^ First
273+ -> Int -- ^ Offset into first
274+ -> Array -- ^ Second
275+ -> Int -- ^ Offset into second
278+equal arrA offA arrB offB count
279+ | wordAligned offA && wordAligned offB = fast 0
280+ | otherwise = slow 0
282+ countWords = count `div` wordFactor
284+ | i >= countWords = slow (i * wordFactor)
286+ | otherwise = fast (i+1)
287+ where a = unsafeIndexWord arrA (offAW+i)
288+ b = unsafeIndexWord arrB (offBW+i)
289+ offAW = offA `div` wordFactor
290+ offBW = offB `div` wordFactor
294+ | otherwise = slow (i+1)
295+ where a = unsafeIndex arrA (offA+i)
296+ b = unsafeIndex arrB (offB+i)