use_is_even_rather_than_modulo (#68301)
This commit is contained in:
committed by
GitHub
parent
3393566b56
commit
c0176c9ee5
@@ -70,7 +70,7 @@ class _MultiWidgetConstructTableState extends State<MultiWidgetConstructTable>
|
||||
// This implementation rebuild the widget tree for every
|
||||
// frame, and is intentionally designed of poor performance
|
||||
// for benchmark purposes.
|
||||
return counter % 2 == 0
|
||||
return counter.isEven
|
||||
? Container(
|
||||
// This key forces rebuilding the element
|
||||
key: ValueKey<int>(widgetCounter + label),
|
||||
|
||||
@@ -132,7 +132,7 @@ class ListItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Image.asset(
|
||||
index % 2 == 0 ? 'food/butternut_squash_soup.png' : 'food/cherry_pie.png',
|
||||
index.isEven ? 'food/butternut_squash_soup.png' : 'food/cherry_pie.png',
|
||||
package: 'flutter_gallery_assets',
|
||||
fit: BoxFit.cover,
|
||||
width: 110,
|
||||
|
||||
@@ -69,7 +69,7 @@ class BenchUpdateManyChildLayers extends SceneBuilderRecorder {
|
||||
final double offsetY = row * cellSize.height;
|
||||
// Retain every other layer, so we exercise the update path 50% of the
|
||||
// time and the retain path the other 50%.
|
||||
final bool shouldRetain = oldLayer != null && (row + col) % 2 == 0;
|
||||
final bool shouldRetain = oldLayer != null && (row + col).isEven;
|
||||
if (shouldRetain) {
|
||||
sceneBuilder.addRetained(oldLayer);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user