optimize `for c in str {`
parent
c7f8f2175b
commit
d71532b64e
|
@ -366,10 +366,12 @@ fn (p mut Parser) gen_for_header(i, tmp, var_typ, val string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (p mut Parser) gen_for_str_header(i, tmp, var_typ, val string) {
|
fn (p mut Parser) gen_for_str_header(i, tmp, var_typ, val string) {
|
||||||
p.genln('array_byte bytes_$tmp = string_bytes( $tmp );')
|
// TODO var_typ is always byte
|
||||||
|
//p.genln('array_byte bytes_$tmp = string_bytes( $tmp );')
|
||||||
p.genln(';\nfor (int $i = 0; $i < $tmp .len; $i ++) {')
|
p.genln(';\nfor (int $i = 0; $i < $tmp .len; $i ++) {')
|
||||||
if val == '_' { return }
|
if val == '_' { return }
|
||||||
p.genln('$var_typ $val = (($var_typ *) bytes_$tmp . data)[$i];')
|
//p.genln('$var_typ $val = (($var_typ *) bytes_$tmp . data)[$i];')
|
||||||
|
p.genln('$var_typ $val = ${tmp}.str[$i];')
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (p mut Parser) gen_for_range_header(i, range_end, tmp, var_type, val string) {
|
fn (p mut Parser) gen_for_range_header(i, range_end, tmp, var_type, val string) {
|
||||||
|
|
Loading…
Reference in New Issue