mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
transformer: minor optimization for 'string literal'.len (#14207)
This commit is contained in:
@@ -636,6 +636,12 @@ pub fn (mut t Transformer) expr(mut node ast.Expr) ast.Expr {
|
||||
}
|
||||
ast.SelectorExpr {
|
||||
node.expr = t.expr(mut node.expr)
|
||||
if mut node.expr is ast.StringLiteral && node.field_name == 'len' {
|
||||
return ast.IntegerLiteral{
|
||||
val: node.expr.val.len.str()
|
||||
pos: node.pos
|
||||
}
|
||||
}
|
||||
}
|
||||
ast.SizeOf {
|
||||
node.expr = t.expr(mut node.expr)
|
||||
|
||||
Reference in New Issue
Block a user