File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -1107,15 +1107,15 @@ replicate n t@(Text a o l)
1107
1107
| isSingleton t = replicateChar n (unsafeHead t)
1108
1108
| otherwise = Text (A. run x) 0 len
1109
1109
where
1110
- len = l `mul` n
1110
+ len = l `mul` n -- TODO: detect overflows
1111
1111
x :: ST s (A. MArray s )
1112
1112
x = do
1113
1113
arr <- A. new len
1114
1114
A. copyI arr 0 a o l
1115
- let loop ! l =
1116
- let l2 = l `shiftL` 1 in
1117
- if l2 > len then A. copyM arr l arr 0 (len - l) >> return arr
1118
- else A. copyM arr l arr 0 l >> loop l2
1115
+ let loop ! l1 =
1116
+ let rest = len - l1 in
1117
+ if rest <= l1 then A. copyM arr l1 arr 0 rest >> return arr
1118
+ else A. copyM arr l1 arr 0 l1 >> loop (l1 `shiftL` 1 )
1119
1119
loop l
1120
1120
{-# INLINE [1] replicate #-}
1121
1121
You can’t perform that action at this time.
0 commit comments