From: John Meacham Date: Fri, 8 Jun 2007 18:23:53 +0000 (+0000) Subject: Speed up number printing and remove the need for Array by using the standard 'intToDi... X-Git-Tag: 2007-09-13~57 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=a642e93ea637d3187d983722b7d13953971277b2;p=ghc-base.git Speed up number printing and remove the need for Array by using the standard 'intToDigit' routine --- diff --git a/Text/Printf.hs b/Text/Printf.hs index ee0b51c..14f57da 100644 --- a/Text/Printf.hs +++ b/Text/Printf.hs @@ -18,7 +18,6 @@ module Text.Printf( ) where import Prelude -import Data.Array import Data.Char import Numeric(showEFloat, showFFloat, showGFloat) import System.IO @@ -221,14 +220,13 @@ itos n = let (q, r) = quotRem n 10 in itos q ++ [toEnum (fromEnum '0' + toInt r)] -chars = array (0,15) (zipWith (,) [0..] "0123456789abcdef") itosb :: Integer -> Integer -> String itosb b n = if n < b then - [chars!n] + [intToDigit $ fromInteger n] else let (q, r) = quotRem n b in - itosb b q ++ [chars!r] + itosb b q ++ [intToDigit $ fromInteger r] stoi :: Int -> String -> (Int, String) stoi a (c:cs) | isDigit c = stoi (a*10 + fromEnum c - fromEnum '0') cs