on master help sign in
simplified compareLengthI with compareSize
6cab130Edward Kmett
Data/Text/Internal/Fusion/Common.hs+3−7
@@ -319,13 +319,9 @@ lengthI (Stream next s0 _len) = loop_length 0 s0
319-- as the number supplied, and hence be more efficient.
319-- as the number supplied, and hence be more efficient.
320compareLengthI :: Integral a => Stream Char -> a -> Ordering
320compareLengthI :: Integral a => Stream Char -> a -> Ordering
321compareLengthI (Stream next s0 len) n =
321compareLengthI (Stream next s0 len) n =
322− case exactly len of
322+ case compareSize len (fromIntegral n) of
323− Nothing
323+ Just o -> o
324− | upperBound n' len < n' -> LT
325− | lowerBound n' len > n' -> GT
326− | otherwise -> loop_cmp 0 s0
324+ Nothing -> loop_cmp 0 s0
327− where n' = fromIntegral n
328− Just i -> compare (fromIntegral i) n
329 where
325 where
330 loop_cmp !z s = case next s of
326 loop_cmp !z s = case next s of
331 Done -> compare z n
327 Done -> compare z n