on master help sign in
Use mul instead of a more expensive check for replicate
commit8ecefd43b8ab10d46abc073e41d766b93d628129 authorBryan O'Sullivan <bos@serpentine.com> dateFri 6 Jun 2014, 00:35 (12 years ago) parent466172d
1 file changed+3−4
Data/Text.hs+3−4
Data/Text.hs+3−4
@@ -193,7 +193,7 @@ module Data.Text
193193import Prelude (Char, Bool(..), Int, Maybe(..), String,
194194 Eq(..), Ord(..), Ordering(..), (++),
195195 Read(..), Show(..),
196− (&&), (||), (+), (-), (.), ($), ($!), (>>), (*),
196+ (&&), (||), (+), (-), (.), ($), ($!), (>>),
197197 maxBound, not, return, otherwise, quot)
198198#if defined(HAVE_DEEPSEQ)
199199import Control.DeepSeq (NFData)
@@ -962,10 +962,9 @@ replicate n t@(Text a o l)
962962 | n <= 0 || l <= 0 = empty
963963 | n == 1 = t
964964 | isSingleton t = replicateChar n (unsafeHead t)
965− | n <= maxBound `quot` l = Text (A.run x) 0 len
966− | otherwise = overflowError "replicate"
965+ | otherwise = Text (A.run x) 0 len
967966 where
968− len = l * n
967+ len = l `mul` n
969968 x = do
970969 arr <- A.new len
971970 let loop !d !i | i >= n = return arr