string.repeat: re-write without a libc function call
parent
1821dac795
commit
a5391c8882
|
@ -1015,9 +1015,11 @@ pub fn (s string) repeat(count int) string {
|
||||||
if count <= 1 {
|
if count <= 1 {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
ret := malloc(s.len * count + 1)
|
mut ret := malloc(s.len * count + 1)
|
||||||
for _ in 0..count {
|
for i in 0..count {
|
||||||
C.strcat(ret, s.str)
|
for j in 0..s.len {
|
||||||
|
ret[i*s.len + j] = s[j]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return string(ret)
|
return string(ret)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue