on master help sign in
simplified compareLengthI with compareSize
commit6cab1308313dd3486b2b3e9714b2421384c91b10 authorEdward Kmett <ekmett@gmail.com> dateFri 4 Apr 2014, 08:19 (13 years ago) parent2be75d4
1 file changed+3−7
Data/Text/Internal/Fusion/Common.hs+3−7
Data/Text/Internal/Fusion/Common.hs+3−7
@@ -319,13 +319,9 @@ lengthI (Stream next s0 _len) = loop_length 0 s0
319319-- as the number supplied, and hence be more efficient.
320320compareLengthI :: Integral a => Stream Char -> a -> Ordering
321321compareLengthI (Stream next s0 len) n =
322− case exactly len of
323− Nothing
324− | upperBound n' len < n' -> LT
325− | lowerBound n' len > n' -> GT
326− | otherwise -> loop_cmp 0 s0
327− where n' = fromIntegral n
328− Just i -> compare (fromIntegral i) n
322+ case compareSize len (fromIntegral n) of
323+ Just o -> o
324+ Nothing -> loop_cmp 0 s0
329325 where
330326 loop_cmp !z s = case next s of
331327 Done -> compare z n