[Patterns] Generate SwitchStatement in kernel AST when possible #51391
Labels
legacy-area-front-end
Legacy: Use area-dart-model instead.
P2
A bug or feature request we're likely to work on
AOT is able to generate
switch
statements overint
and enums more efficiently using jump table or binary search. However, these optimizations are applied only toSwitchStatement
kernel AST nodes.With new patterns language feature, front-end now represents
switch
statements as a sequence ofif
statements, even if patterns are not used. As a result, switch optimizations are disabled in the new language version.It would be nice if front-end would be able to generate old
SwitchStatement
kernel AST nodes if patterns are not used, at least for switch statements overint
and enum expressions.Example:
Kernel AST before patterns:
Code generated by AOT compiler before patterns:
Kernel AST with
--enable-experiment=patterns
:Code generated by AOT compiler with
--enable-experiment=patterns
:@johnniwinther
The text was updated successfully, but these errors were encountered: