File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 44module cflag
55
66import os
7+ import strings
78
89// parsed cflag
910pub struct CFlag {
@@ -24,7 +25,7 @@ const fexisting_literal = r'$first_existing'
2425
2526// expand the flag value
2627pub fn (cf &CFlag) eval () string {
27- mut value := ''
28+ mut value_builder := strings. new_builder ( 10 * cf.value.len)
2829 cflag_eval_outer_loop: for i := 0 ; i < cf.value.len; i++ {
2930 x := cf.value[i]
3031 if x == `$` {
@@ -37,17 +38,17 @@ pub fn (cf &CFlag) eval() string {
3738 for spath in svalues {
3839 if os.exists (spath) {
3940 // found_spath = spath
40- value + = spath
41+ value_builder. write_string ( spath)
4142 continue cflag_eval_outer_loop
4243 }
4344 }
4445 panic ('>> error: none of the paths ${svalues} exist' )
4546 continue
4647 }
4748 }
48- value + = x.ascii_str ()
49+ value_builder. write_string ( x.ascii_str () )
4950 }
50- return value
51+ return value_builder. str ()
5152}
5253
5354// format flag
@@ -79,7 +80,7 @@ pub fn (cflags []CFlag) c_options_after_target_msvc() []string {
7980
8081pub fn (cflags []CFlag) c_options_before_target () []string {
8182 defines , others , _ := cflags.defines_others_libs ()
82- mut args := []string {}
83+ mut args := []string {cap: defines.len + others.len }
8384 args << defines
8485 args << others
8586 return args
You can’t perform that action at this time.
0 commit comments