Changeset 15365 for src/Pugs/Parser

Show
Ignore:
Timestamp:
02/26/07 18:00:32 (21 months ago)
Author:
audreyt
Message:

* Pugs.Parser.Program: Make decodeProgram sufficiently

chunky-lazy so memory use stays constant for source
code size >4k.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Parser/Program.hs

    r15297 r15365  
    3333 
    3434decodeProgram :: String -> String 
    35 decodeProgram str = removeCRLF $! case detectSourceEncoding str of 
    36     UTF8 xs                 -> decodeUTF8 xs 
    37     UTF16 LittleEndian xs   -> decodeUTF16LE xs 
    38     UTF16 BigEndian xs      -> decodeUTF16BE xs 
    39     UTF32 LittleEndian xs   -> decodeUTF32LE xs 
    40     UTF32 BigEndian xs      -> decodeUTF32BE xs 
     35decodeProgram str = case detectSourceEncoding str of 
     36    UTF8 xs                 -> decodeUTF8    (removeCRLF xs) 
     37    UTF16 LittleEndian xs   -> decodeUTF16LE (removeCRLF xs) 
     38    UTF16 BigEndian xs      -> decodeUTF16BE (removeCRLF xs) 
     39    UTF32 LittleEndian xs   -> decodeUTF32LE (removeCRLF xs) 
     40    UTF32 BigEndian xs      -> decodeUTF32BE (removeCRLF xs) 
    4141    where 
    42     removeCRLF ('\r':'\n':xs)   = let rest = removeCRLF xs in seq rest ('\n':rest) 
    43     removeCRLF (x:xs)           = let rest = removeCRLF xs in seq rest (x:rest) 
     42    removeCRLF ('\r':'\n':xs)   = '\n':removeCRLF xs 
     43    removeCRLF (x:xs)           = x:removeCRLF xs 
    4444    removeCRLF []               = [] 
    4545    decodeUTF16BE (a:b:c:d:xs)