Open
Description
Given this code which has an invocation as an argument to a function:
void a() {
b(expensiveFunction());
}
void b(String a) { // Perform "Inline Method" here
print(a);
print(a);
}
int count = 1;
String expensiveFunction() => '${count++}';
If you use "Inline Method" on b
(which maybe should be "Inline Function"?), you end up with this:
void a() {
print(expensiveFunction());
print(expensiveFunction());
}
int count = 1;
String expensiveFunction() => '${count++}';
expensiveFunction()
is now called twice. This could be more expensive than the original code, and if the function has side-effects could change the behaviour.
Local variables should probably be introduced for such cases, although this might get noisy (and appear unnecessary) for getters?
Metadata
Metadata
Assignees
Labels
A lower priority bug or feature requestFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.Issues with analysis server refactoringsIssues related to some aspect of the analysis serverIncorrect behavior (everything from a crash to more subtle misbehavior)