mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin: cleanup string.v
This commit is contained in:
parent
6450fda938
commit
e6011e83ce
@ -243,7 +243,7 @@ fn (a string) clone_static() string {
|
||||
|
||||
// clone returns a copy of the V string `a`.
|
||||
pub fn (a string) clone() string {
|
||||
if a == '' {
|
||||
if a.len == 0 {
|
||||
// TODO perf? an extra check in each clone() is not nice.
|
||||
return ''
|
||||
}
|
||||
@ -1733,7 +1733,8 @@ pub fn (s string) repeat(count int) string {
|
||||
}
|
||||
|
||||
// fields returns a string array of the string split by `\t` and ` `
|
||||
// Example: assert '\t\tv = v'.fields() == ['', '', 'v', '=', 'v']
|
||||
// Example: assert '\t\tv = v'.fields() == ['v', '=', 'v']
|
||||
// Example: assert ' sss ssss'.fields() == ['sss', 'ssss']
|
||||
pub fn (s string) fields() []string {
|
||||
mut res := []string{}
|
||||
mut word_start := 0
|
||||
@ -1827,11 +1828,3 @@ pub fn (s string) strip_margin_custom(del byte) string {
|
||||
return ret.vstring_with_len(count)
|
||||
}
|
||||
}
|
||||
|
||||
// split_by_whitespace - extract only the non whitespace tokens/words from the given string `s`.
|
||||
// example: ' sss ssss'.split_by_whitespace() => ['sss', 'ssss']
|
||||
|
||||
[deprecated: 'use string.fields() instead']
|
||||
pub fn (s string) split_by_whitespace() []string {
|
||||
return s.fields()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user