mirror of
https://github.com/vlang/v.git
synced 2025-09-16 07:52:32 +03:00
js: change codegen for match statement, speedup string.split_into_lines (#12157)
This commit is contained in:
parent
cfc56b24fb
commit
22962dd2d2
3 changed files with 57 additions and 25 deletions
|
@ -755,18 +755,11 @@ pub fn (s string) split_into_lines() []string {
|
|||
if s.len == 0 {
|
||||
return res
|
||||
}
|
||||
mut start := 0
|
||||
mut end := 0
|
||||
for i := 0; i < s.len; i++ {
|
||||
if s[i] == 10 {
|
||||
end = if i > 0 && s[i - 1] == 13 { i - 1 } else { i }
|
||||
res << if start == end { '' } else { s[start..end] }
|
||||
start = i + 1
|
||||
}
|
||||
}
|
||||
if start < s.len {
|
||||
res << s[start..]
|
||||
}
|
||||
#res.arr.arr = s.str.split("\n")
|
||||
#if (res.arr.arr[res.arr.arr.length-1] == "") res.arr.arr.pop();
|
||||
#res.arr.len = new int(res.arr.arr.length);
|
||||
#res.arr.cap = new int(res.arr.arr.length);
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue