@@ -308,6 +308,7 @@ pub fn (s string) len_utf8() int {
308308
309309// clone_static returns an independent copy of a given array.
310310// It should be used only in -autofree generated code.
311+ [inline ]
311312fn (a string) clone_static () string {
312313 return a.clone ()
313314}
@@ -565,56 +566,67 @@ pub fn (s string) normalize_tabs(tab_len int) string {
565566}
566567
567568// bool returns `true` if the string equals the word "true" it will return `false` otherwise.
569+ [inline ]
568570pub fn (s string) bool () bool {
569571 return s == 'true' || s == 't' // TODO t for pg, remove
570572}
571573
572574// int returns the value of the string as an integer `'1'.int() == 1`.
575+ [inline ]
573576pub fn (s string) int () int {
574577 return int (strconv.common_parse_int (s, 0 , 32 , false , false ) or { 0 })
575578}
576579
577580// i64 returns the value of the string as i64 `'1'.i64() == i64(1)`.
581+ [inline ]
578582pub fn (s string) i64 () i64 {
579583 return strconv.common_parse_int (s, 0 , 64 , false , false ) or { 0 }
580584}
581585
582586// i8 returns the value of the string as i8 `'1'.i8() == i8(1)`.
587+ [inline ]
583588pub fn (s string) i8 () i8 {
584589 return i8 (strconv.common_parse_int (s, 0 , 8 , false , false ) or { 0 })
585590}
586591
587592// i16 returns the value of the string as i16 `'1'.i16() == i16(1)`.
593+ [inline ]
588594pub fn (s string) i16 () i16 {
589595 return i16 (strconv.common_parse_int (s, 0 , 16 , false , false ) or { 0 })
590596}
591597
592598// f32 returns the value of the string as f32 `'1.0'.f32() == f32(1)`.
599+ [inline ]
593600pub fn (s string) f32 () f32 {
594601 return f32 (strconv.atof64 (s) or { 0 })
595602}
596603
597604// f64 returns the value of the string as f64 `'1.0'.f64() == f64(1)`.
605+ [inline ]
598606pub fn (s string) f64 () f64 {
599607 return strconv.atof64 (s) or { 0 }
600608}
601609
602610// u8 returns the value of the string as u8 `'1'.u8() == u8(1)`.
611+ [inline ]
603612pub fn (s string) u8 () u8 {
604613 return u8 (strconv.common_parse_uint (s, 0 , 8 , false , false ) or { 0 })
605614}
606615
607616// u16 returns the value of the string as u16 `'1'.u16() == u16(1)`.
617+ [inline ]
608618pub fn (s string) u16 () u16 {
609619 return u16 (strconv.common_parse_uint (s, 0 , 16 , false , false ) or { 0 })
610620}
611621
612622// u32 returns the value of the string as u32 `'1'.u32() == u32(1)`.
623+ [inline ]
613624pub fn (s string) u32 () u32 {
614625 return u32 (strconv.common_parse_uint (s, 0 , 32 , false , false ) or { 0 })
615626}
616627
617628// u64 returns the value of the string as u64 `'1'.u64() == u64(1)`.
629+ [inline ]
618630pub fn (s string) u64 () u64 {
619631 return strconv.common_parse_uint (s, 0 , 64 , false , false ) or { 0 }
620632}
@@ -624,6 +636,7 @@ pub fn (s string) u64() u64 {
624636// This method directly exposes the `parse_int` function from `strconv`
625637// as a method on `string`. For more advanced features,
626638// consider calling `strconv.common_parse_int` directly.
639+ [inline ]
627640pub fn (s string) parse_uint (_base int , _bit_size int ) ! u64 {
628641 return strconv.parse_uint (s, _base, _bit_size)
629642}
@@ -644,6 +657,7 @@ pub fn (s string) parse_uint(_base int, _bit_size int) !u64 {
644657// This method directly exposes the `parse_uint` function from `strconv`
645658// as a method on `string`. For more advanced features,
646659// consider calling `strconv.common_parse_uint` directly.
660+ [inline ]
647661pub fn (s string) parse_int (_base int , _bit_size int ) ! i64 {
648662 return strconv.parse_int (s, _base, _bit_size)
649663}
@@ -791,6 +805,7 @@ pub fn (s string) rsplit_any(delim string) []string {
791805// Example: assert 'A B C'.split(' ') == ['A','B','C']
792806// If `delim` is empty the string is split by it's characters.
793807// Example: assert 'DEF'.split('') == ['D','E','F']
808+ [inline ]
794809pub fn (s string) split (delim string ) []string {
795810 return s.split_nth (delim, 0 )
796811}
@@ -799,6 +814,7 @@ pub fn (s string) split(delim string) []string {
799814// Example: assert 'A B C'.rsplit(' ') == ['C','B','A']
800815// If `delim` is empty the string is split by it's characters.
801816// Example: assert 'DEF'.rsplit('') == ['F','E','D']
817+ [inline ]
802818pub fn (s string) rsplit (delim string ) []string {
803819 return s.rsplit_nth (delim, 0 )
804820}
@@ -1018,6 +1034,7 @@ pub fn (s string) split_into_lines() []string {
10181034}
10191035
10201036// used internally for [2..4]
1037+ [inline ]
10211038fn (s string) substr2 (start int , _end int , end_max bool ) string {
10221039 end := if end_max { s.len } else { _end }
10231040 return s.substr (start, end)
@@ -1561,6 +1578,7 @@ pub fn (s string) find_between(start string, end string) string {
15611578
15621579// trim_space strips any of ` `, `\n`, `\t`, `\v`, `\f`, `\r` from the start and end of the string.
15631580// Example: assert ' Hello V '.trim_space() == 'Hello V'
1581+ [inline ]
15641582pub fn (s string) trim_space () string {
15651583 return s.trim (' \n\t\v\f\r ' )
15661584}
@@ -1719,16 +1737,19 @@ fn compare_lower_strings(a &string, b &string) int {
17191737}
17201738
17211739// sort_ignore_case sorts the string array using case insesitive comparing.
1740+ [inline ]
17221741pub fn (mut s []string) sort_ignore_case () {
17231742 s.sort_with_compare (compare_lower_strings)
17241743}
17251744
17261745// sort_by_len sorts the the string array by each string's `.len` length.
1746+ [inline ]
17271747pub fn (mut s []string) sort_by_len () {
17281748 s.sort_with_compare (compare_strings_by_len)
17291749}
17301750
17311751// str returns a copy of the string
1752+ [inline ]
17321753pub fn (s string) str () string {
17331754 return s.clone ()
17341755}
@@ -1914,6 +1935,7 @@ pub fn (s string) all_after_first(sub string) string {
19141935// Example: assert '23:34:45.234'.after(':') == '45.234'
19151936// Example: assert 'abcd'.after('z') == 'abcd'
19161937// TODO: deprecate either .all_after_last or .after
1938+ [inline ]
19171939pub fn (s string) after (sub string ) string {
19181940 return s.all_after_last (sub)
19191941}
@@ -1973,6 +1995,7 @@ pub fn (a []string) join(sep string) string {
19731995}
19741996
19751997// join joins a string array into a string using a `\n` newline delimiter.
1998+ [inline ]
19761999pub fn (s []string) join_lines () string {
19772000 return s.join ('\n ' )
19782001}
@@ -2107,6 +2130,7 @@ pub fn (s string) fields() []string {
21072130// this is a string,
21082131// Everything before the first | is removed'
21092132// ```
2133+ [inline ]
21102134pub fn (s string) strip_margin () string {
21112135 return s.strip_margin_custom (`|` )
21122136}
@@ -2360,6 +2384,7 @@ pub fn (name string) match_glob(pattern string) bool {
23602384}
23612385
23622386// is_ascii returns true if all characters belong to the US-ASCII set ([` `..`~`])
2387+ [inline ]
23632388pub fn (s string) is_ascii () bool {
23642389 return ! s.bytes ().any (it < u8 (` ` ) || it > u8 (`~` ))
23652390}
0 commit comments