#2289: Needless reboxing of values when returning from a tight loop
----------------------------------------+-----------------------------------
Reporter: dons | Owner:
Type: run-time performance bug | Status: new
Priority: normal | Milestone: 6.10 branch
Component: Compiler | Version: 6.8.2
Severity: normal | Resolution:
Keywords: boxing, loops, performance | Difficulty: Unknown
Testcase: | Architecture: Unknown
Os: Unknown |
----------------------------------------+-----------------------------------
Comment (by dons):
Another case we'd like genralised CPR to work is for sum types.
Consider the task of summing integers from a file, one per line. We need
to parse
each line, returning possibly success, in a tight loop:
{{{
import qualified Data.ByteString.Char8 as S
main = print . go 0 =<< S.getContents
where
go !n s = case S.readInt s of
S.Nothing -> n
S.Just (k,t) -> go (n+k) (S.tail t)
}}}
Where
{{{
readInt :: ByteString -> Maybe (Int, ByteString)
}}}
We'd like the Just/Nothing tag returned in a register, in an ideal world.
And the components
of the pair as well. Currently we have to monomorphise the type, and
flatten it , to get register returns here.
Note that Clean uses a triple of (Bool, Int, String) for this kind of
thing.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2289#comment:9>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs