on master help sign in
Replace 3 strict tuples with one strict quad

--HG-- extra : convert_revision : 23f66664fced41113db6f58702ee8d96fd132ce1

commit70c5fe54993078912b69ba9aa00b736fadb944ff authorBryan O'Sullivan <bos@serpentine.com> dateMon 19 Jan 2009, 11:47 (18 years ago) parentc06d2e2
1 file changed+42−40
Data/Text/Fusion.hs+42−40
Data/Text/Fusion.hs+42−40
@@ -33,6 +33,8 @@ default(Int)
3333infixl 2 :!:
3434data PairS a b = !a :!: !b
3535
36+data T4 a b c d = T4 !a !b !c !d
37+
3638data Switch = S1 | S2
3739
3840data EitherS a b = LeftS !a | RightS !b
@@ -217,36 +219,36 @@ restream ASCII (Stream next0 s0 len) = Stream next s0 (len*2)
217219 Yield x xs -> Yield x' xs
218220 where x' = fromIntegral (ord x) :: Word8
219221restream Utf8 (Stream next0 s0 len) =
220− Stream next ((Just s0) :!: Nothing :!: Nothing :!: Nothing) (len*2)
222+ Stream next (T4 (Just s0) Nothing Nothing Nothing) (len*2)
221223 where
222224 {-# INLINE next #-}
223− next ((Just s) :!: Nothing :!: Nothing :!: Nothing) = case next0 s of
225+ next (T4 (Just s) Nothing Nothing Nothing) = case next0 s of
224226 Done -> Done
225− Skip s' -> Skip ((Just s') :!: Nothing :!: Nothing :!: Nothing)
227+ Skip s' -> Skip (T4 (Just s') Nothing Nothing Nothing)
226228 Yield x xs
227− | n <= 0x7F -> Yield c ((Just xs) :!: Nothing :!: Nothing :!: Nothing)
228− | n <= 0x07FF -> Yield (fst c2) ((Just xs) :!: (Just $ snd c2) :!: Nothing :!: Nothing)
229− | n <= 0xFFFF -> Yield (fst3 c3) ((Just xs) :!: (Just $ snd3 c3) :!: (Just $ trd3 c3) :!: Nothing)
230− | otherwise -> Yield (fst4 c4) ((Just xs) :!: (Just $ snd4 c4) :!: (Just $ trd4 c4) :!: (Just $ fth4 c4))
229+ | n <= 0x7F -> Yield c (T4 (Just xs) Nothing Nothing Nothing)
230+ | n <= 0x07FF -> Yield (fst c2) (T4 (Just xs) (Just $ snd c2) Nothing Nothing)
231+ | n <= 0xFFFF -> Yield (fst3 c3) (T4 (Just xs) (Just $ snd3 c3) (Just $ trd3 c3) Nothing)
232+ | otherwise -> Yield (fst4 c4) (T4 (Just xs) (Just $ snd4 c4) (Just $ trd4 c4) (Just $ fth4 c4))
231233 where
232234 n = ord x
233235 c = fromIntegral n
234236 c2 = U8.ord2 x
235237 c3 = U8.ord3 x
236238 c4 = U8.ord4 x
237− next ((Just s) :!: (Just x2) :!: Nothing :!: Nothing) = Yield x2 ((Just s) :!: Nothing :!: Nothing :!: Nothing)
238− next ((Just s) :!: (Just x2) :!: x3 :!: Nothing) = Yield x2 ((Just s) :!: x3 :!: Nothing :!: Nothing)
239− next ((Just s) :!: (Just x2) :!: x3 :!: x4) = Yield x2 ((Just s) :!: x3 :!: x4 :!: Nothing)
239+ next (T4 (Just s) (Just x2) Nothing Nothing) = Yield x2 (T4 (Just s) Nothing Nothing Nothing)
240+ next (T4 (Just s) (Just x2) x3 Nothing) = Yield x2 (T4 (Just s) x3 Nothing Nothing)
241+ next (T4 (Just s) (Just x2) x3 x4) = Yield x2 (T4 (Just s) x3 x4 Nothing)
240242restream Utf16BE (Stream next0 s0 len) =
241− Stream next (Just s0 :!: Nothing :!: Nothing :!: Nothing) (len*2)
243+ Stream next (T4 (Just s0) Nothing Nothing Nothing) (len*2)
242244 where
243245 {-# INLINE next #-}
244− next (Just s :!: Nothing :!: Nothing :!: Nothing) = case next0 s of
246+ next (T4 (Just s) Nothing Nothing Nothing) = case next0 s of
245247 Done -> Done
246− Skip s' -> Skip (Just s' :!: Nothing :!: Nothing :!: Nothing)
248+ Skip s' -> Skip (T4 (Just s') Nothing Nothing Nothing)
247249 Yield x xs
248− | n < 0x10000 -> Yield (fromIntegral $ shiftR n 8) (Just xs :!: Just (fromIntegral n) :!: Nothing :!: Nothing)
249− | otherwise -> Yield c1 (Just xs :!: Just c2 :!: Just c3 :!: Just c4)
250+ | n < 0x10000 -> Yield (fromIntegral $ shiftR n 8) (T4 (Just xs) (Just (fromIntegral n)) Nothing Nothing)
251+ | otherwise -> Yield c1 (T4 (Just xs) (Just c2) (Just c3) (Just c4))
250252 where
251253 n = ord x
252254 n1 = n - 0x10000
@@ -255,19 +257,19 @@ restream Utf16BE (Stream next0 s0 len) =
255257 n2 = n1 .&. 0x3FF
256258 c3 = fromIntegral (shiftR n2 8 + 0xDC)
257259 c4 = fromIntegral n2
258− next ((Just s) :!: (Just x2) :!: Nothing :!: Nothing) = Yield x2 ((Just s) :!: Nothing :!: Nothing :!: Nothing)
259− next ((Just s) :!: (Just x2) :!: x3 :!: Nothing) = Yield x2 ((Just s) :!: x3 :!: Nothing :!: Nothing)
260− next ((Just s) :!: (Just x2) :!: x3 :!: x4) = Yield x2 ((Just s) :!: x3 :!: x4 :!: Nothing)
260+ next (T4 (Just s) (Just x2) Nothing Nothing) = Yield x2 (T4 (Just s) Nothing Nothing Nothing)
261+ next (T4 (Just s) (Just x2) x3 Nothing) = Yield x2 (T4 (Just s) x3 Nothing Nothing)
262+ next (T4 (Just s) (Just x2) x3 x4) = Yield x2 (T4 (Just s) x3 x4 Nothing)
261263restream Utf16LE (Stream next0 s0 len) =
262− Stream next (Just s0 :!: Nothing :!: Nothing :!: Nothing) (len*2)
264+ Stream next (T4 (Just s0) Nothing Nothing Nothing) (len*2)
263265 where
264266 {-# INLINE next #-}
265− next (Just s :!: Nothing :!: Nothing :!: Nothing) = case next0 s of
267+ next (T4 (Just s) Nothing Nothing Nothing) = case next0 s of
266268 Done -> Done
267− Skip s' -> Skip (Just s' :!: Nothing :!: Nothing :!: Nothing)
269+ Skip s' -> Skip (T4 (Just s') Nothing Nothing Nothing)
268270 Yield x xs
269− | n < 0x10000 -> Yield (fromIntegral n) (Just xs :!: Just (fromIntegral $ shiftR n 8) :!: Nothing :!: Nothing)
270− | otherwise -> Yield c1 (Just xs :!: Just c2 :!: Just c3 :!: Just c4)
271+ | n < 0x10000 -> Yield (fromIntegral n) (T4 (Just xs) (Just (fromIntegral $ shiftR n 8)) Nothing Nothing)
272+ | otherwise -> Yield c1 (T4 (Just xs) (Just c2) (Just c3) (Just c4))
271273 where
272274 n = ord x
273275 n1 = n - 0x10000
@@ -276,43 +278,43 @@ restream Utf16LE (Stream next0 s0 len) =
276278 n2 = n1 .&. 0x3FF
277279 c4 = fromIntegral (shiftR n2 8 + 0xDC)
278280 c3 = fromIntegral n2
279− next ((Just s) :!: (Just x2) :!: Nothing :!: Nothing) = Yield x2 ((Just s) :!: Nothing :!: Nothing :!: Nothing)
280− next ((Just s) :!: (Just x2) :!: x3 :!: Nothing) = Yield x2 ((Just s) :!: x3 :!: Nothing :!: Nothing)
281− next ((Just s) :!: (Just x2) :!: x3 :!: x4) = Yield x2 ((Just s) :!: x3 :!: x4 :!: Nothing)
281+ next (T4 (Just s) (Just x2) Nothing Nothing) = Yield x2 (T4 (Just s) Nothing Nothing Nothing)
282+ next (T4 (Just s) (Just x2) x3 Nothing) = Yield x2 (T4 (Just s) x3 Nothing Nothing)
283+ next (T4 (Just s) (Just x2) x3 x4) = Yield x2 (T4 (Just s) x3 x4 Nothing)
282284restream Utf32BE (Stream next0 s0 len) =
283− Stream next (Just s0 :!: Nothing :!: Nothing :!: Nothing) (len*2)
285+ Stream next (T4 (Just s0) Nothing Nothing Nothing) (len*2)
284286 where
285287 {-# INLINE next #-}
286− next (Just s :!: Nothing :!: Nothing :!: Nothing) = case next0 s of
288+ next (T4 (Just s) Nothing Nothing Nothing) = case next0 s of
287289 Done -> Done
288− Skip s' -> Skip (Just s' :!: Nothing :!: Nothing :!: Nothing)
289− Yield x xs -> Yield c1 (Just xs :!: Just c2 :!: Just c3 :!: Just c4)
290+ Skip s' -> Skip (T4 (Just s') Nothing Nothing Nothing)
291+ Yield x xs -> Yield c1 (T4 (Just xs) (Just c2) (Just c3) (Just c4))
290292 where
291293 n = ord x
292294 c1 = fromIntegral $ shiftR n 24
293295 c2 = fromIntegral $ shiftR n 16
294296 c3 = fromIntegral $ shiftR n 8
295297 c4 = fromIntegral n
296− next ((Just s) :!: (Just x2) :!: Nothing :!: Nothing) = Yield x2 ((Just s) :!: Nothing :!: Nothing :!: Nothing)
297− next ((Just s) :!: (Just x2) :!: x3 :!: Nothing) = Yield x2 ((Just s) :!: x3 :!: Nothing :!: Nothing)
298− next ((Just s) :!: (Just x2) :!: x3 :!: x4) = Yield x2 ((Just s) :!: x3 :!: x4 :!: Nothing)
298+ next (T4 (Just s) (Just x2) Nothing Nothing) = Yield x2 (T4 (Just s) Nothing Nothing Nothing)
299+ next (T4 (Just s) (Just x2) x3 Nothing) = Yield x2 (T4 (Just s) x3 Nothing Nothing)
300+ next (T4 (Just s) (Just x2) x3 x4) = Yield x2 (T4 (Just s) x3 x4 Nothing)
299301restream Utf32LE (Stream next0 s0 len) =
300− Stream next (Just s0 :!: Nothing :!: Nothing :!: Nothing) (len*2)
302+ Stream next (T4 (Just s0) Nothing Nothing Nothing) (len*2)
301303 where
302304 {-# INLINE next #-}
303− next (Just s :!: Nothing :!: Nothing :!: Nothing) = case next0 s of
305+ next (T4 (Just s) Nothing Nothing Nothing) = case next0 s of
304306 Done -> Done
305− Skip s' -> Skip (Just s' :!: Nothing :!: Nothing :!: Nothing)
306− Yield x xs -> Yield c1 (Just xs :!: Just c2 :!: Just c3 :!: Just c4)
307+ Skip s' -> Skip (T4 (Just s') Nothing Nothing Nothing)
308+ Yield x xs -> Yield c1 (T4 (Just xs) (Just c2) (Just c3) (Just c4))
307309 where
308310 n = ord x
309311 c4 = fromIntegral $ shiftR n 24
310312 c3 = fromIntegral $ shiftR n 16
311313 c2 = fromIntegral $ shiftR n 8
312314 c1 = fromIntegral n
313− next ((Just s) :!: (Just x2) :!: Nothing :!: Nothing) = Yield x2 ((Just s) :!: Nothing :!: Nothing :!: Nothing)
314− next ((Just s) :!: (Just x2) :!: x3 :!: Nothing) = Yield x2 ((Just s) :!: x3 :!: Nothing :!: Nothing)
315− next ((Just s) :!: (Just x2) :!: x3 :!: x4) = Yield x2 ((Just s) :!: x3 :!: x4 :!: Nothing)
315+ next (T4 (Just s) (Just x2) Nothing Nothing) = Yield x2 (T4 (Just s) Nothing Nothing Nothing)
316+ next (T4 (Just s) (Just x2) x3 Nothing) = Yield x2 (T4 (Just s) x3 Nothing Nothing)
317+ next (T4 (Just s) (Just x2) x3 x4) = Yield x2 (T4 (Just s) x3 x4 Nothing)
316318{-# INLINE restream #-}
317319
318320