1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builtin,strconv: speedup str.int() conversions (without -prod)

This commit is contained in:
Delyan Angelov
2022-09-08 11:09:13 +03:00
parent a462610376
commit fc8e3d0971
10 changed files with 63 additions and 30 deletions

View File

@@ -1818,6 +1818,7 @@ pub fn (s []string) join_lines() string {
// reverse returns a reversed string.
// Example: assert 'Hello V'.reverse() == 'V olleH'
[direct_array_access]
pub fn (s string) reverse() string {
if s.len == 0 || s.len == 1 {
return s.clone()
@@ -1870,6 +1871,7 @@ pub fn (s string) bytes() []u8 {
}
// repeat returns a new string with `count` number of copies of the string it was called on.
[direct_array_access]
pub fn (s string) repeat(count int) string {
if count < 0 {
panic('string.repeat: count is negative: $count')