mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
string.repeat: re-write without a libc function call
This commit is contained in:
parent
1821dac795
commit
a5391c8882
@ -1015,9 +1015,11 @@ pub fn (s string) repeat(count int) string {
|
||||
if count <= 1 {
|
||||
return s
|
||||
}
|
||||
ret := malloc(s.len * count + 1)
|
||||
for _ in 0..count {
|
||||
C.strcat(ret, s.str)
|
||||
mut ret := malloc(s.len * count + 1)
|
||||
for i in 0..count {
|
||||
for j in 0..s.len {
|
||||
ret[i*s.len + j] = s[j]
|
||||
}
|
||||
}
|
||||
return string(ret)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user