Skip to content
  • Daniel Gröber (dxld)'s avatar
    Use lazyness for FastString's z-encoding memoization · 4cf91d1a
    Daniel Gröber (dxld) authored and Marge Bot's avatar Marge Bot committed
    Having an IORef in FastString to memoize the z-encoded version is
    unecessary because there is this amazing thing Haskell can do natively,
    it's called "lazyness" :)
    
    We simply remove the UNPACK and strictness annotations from the constructor
    field corresponding to the z-encoding, making it lazy, and store the
    (pure) z-encoded string there.
    
    The only complication here is 'hasZEncoding' which allows cheking if a
    z-encoding was computed for a given string. Since this is only used for
    compiler performance statistics though it's not actually necessary to have
    the current per-string granularity.
    
    Instead I add a global IORef counter to the FastStringTable and use
    unsafePerformIO to increment the counter whenever a lazy z-encoding is
    forced.
    4cf91d1a