Skip to content
  • Andreas Klebinger's avatar
    Optimize unpackCString# to allocate less. · 88bf81aa
    Andreas Klebinger authored and Marge Bot's avatar Marge Bot committed
    unpackCString# is a recursive function which for each iteration
    returns a Cons cell containing the current Char, and a thunk for
    unpacking the rest of the string.
    
    In this patch we change from storing addr + offset inside this thunk
    to storing only the addr, simply incrementing the address on each
    iteration.
    
    This saves one word of allocation per unpacked character.
    For a program like "main = print "<largishString>" this amounts
    to 2-3% fewer % in bytes allocated.
    
    I also removed the now redundant local unpack definitions.
    This removes one call per unpack operation.
    88bf81aa