Unverified Commit 7937b1d5 authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

Skip the iteration in Layer._fireCompositionCallbacks if the callbacks map is empty (#130438)

This was showing up as a hot spot in some benchmarks and profiles. This
function is called frequently during frame builds and often has an empty
map. There may be significant overhead from obtaining the values
iterator and cloning it into a list.

See https://github.com/flutter/flutter/issues/130339
parent 1bfe2289
......@@ -172,6 +172,9 @@ abstract class Layer with DiagnosticableTreeMixin {
}
void _fireCompositionCallbacks({required bool includeChildren}) {
if (_callbacks.isEmpty) {
return;
}
for (final VoidCallback callback in List<VoidCallback>.of(_callbacks.values)) {
callback();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment