-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: division_optimization
#3930
Comments
@rakudrama Is this still valid advice for dart2js? Would we recommend this lint to our users? |
I would not give this advice on the basis of efficiency.The performance characteristics of web and native are probably quite different. For dart2js, which one is faster depends on the types and values of the inputs. An optimizing compiler might recognize the less efficient form and convert it to something more like the more efficient form, and that might depend on what the compiler can tell about the values in play. That said, dart2js does not know about the combination. It knows some tricks for I would give the advice to prefer
|
Just a note: this diagnostic is already implemented, in the analyzer as a Hint (default enabled for everyone). So we may still transfer the diagnostic to this codebase as part of dart-lang/sdk#50796, acknowledging that it has always been the case that we can implement a better diagnostic and retire this |
It would make more sense to me to not introduce the lint just to remove it later, but I could live with the other. |
Given that dart-lang/sdk#50942 has a lot of complexity, I'm in favor of not blocking the HintCode-removal on it, and instead, migrating division_optimization as it exists today from a Hint to a Lint. |
Fixes dart-lang/linter#3930 This allows us to remove (softly) the DIVISION_OPTIMIZATION HintCode, which was not deemed a good candidate for a Warning. Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try Change-Id: Iac48c94687d0b6b32c971e9f366ccb96adf34429 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378543 Reviewed-by: Phil Quitslund <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
Complete with dart-lang/sdk@b946c47 |
division_optimization
Description
This rule replaces the current HintCode named
division_optimization
. As part of removing the notion of "hints," dart-lang/sdk#50796, we want to movedivision_optimization
to the linter.Details
The operation 'x ~/ y' is more efficient than '(x / y).toInt()'. Try re-writing the expression to use the '~/' operator.
Kind
Efficiency?
Bad Examples
Good Examples
Discussion
Add any other motivation or useful context here.
Discussion checklist
The text was updated successfully, but these errors were encountered: