summaryrefslogtreecommitdiff
path: root/libraries/base/Text
diff options
context:
space:
mode:
authorJohn Meacham <john@repetae.net>2007-06-08 18:23:53 +0000
committerJohn Meacham <john@repetae.net>2007-06-08 18:23:53 +0000
commit4736c6eb39afbd1b2babc9093cb9eb98fcfff6ae (patch)
tree958f986d0ce05779e7a5c608427c51e528a13f11 /libraries/base/Text
parent2a9932d29d9c3a9f74a60ea2b42ac8c0cb95ede3 (diff)
downloadhaskell-4736c6eb39afbd1b2babc9093cb9eb98fcfff6ae.tar.gz
Speed up number printing and remove the need for Array by using the standard 'intToDigit' routine
Diffstat (limited to 'libraries/base/Text')
-rw-r--r--libraries/base/Text/Printf.hs6
1 files changed, 2 insertions, 4 deletions
diff --git a/libraries/base/Text/Printf.hs b/libraries/base/Text/Printf.hs
index ee0b51ce97..14f57da83f 100644
--- a/libraries/base/Text/Printf.hs
+++ b/libraries/base/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