#14222: Simple text fusion example results in rather duplicative code -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): By contrast, a relatively naive translation to C compiled with `gcc -O0` requires less than half the code, {{{#!c #include <stdint.h> #include <stdbool.h> bool isNumber(uint16_t c) { return '0' <= c && c <= '9'; } bool isNumeric(uint16_t c) { if (isNumber(c)) return true; switch (c) { case 'e': case 'E': case '.': case '-': case '+': return true; default: return false; } } bool test(uint16_t *buf, int len) { for (int i=0; i<len; i++) { if (!isNumeric(buf[i])) return false; } for (int i=0; i<len; i++) { if (isNumber(buf[i])) return true; } return false; } }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14222#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler