Unverified Commit dacab7de authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

Improve efficiency of copying the animation ObserverList in notifyListeners (#102536)

parent 79d4bdd1
......@@ -137,7 +137,7 @@ mixin AnimationLocalListenersMixin {
@protected
@pragma('vm:notify-debugger-on-exception')
void notifyListeners() {
final List<VoidCallback> localListeners = List<VoidCallback>.of(_listeners);
final List<VoidCallback> localListeners = _listeners.toList(growable: false);
for (final VoidCallback listener in localListeners) {
InformationCollector? collector;
assert(() {
......@@ -226,7 +226,7 @@ mixin AnimationLocalStatusListenersMixin {
@protected
@pragma('vm:notify-debugger-on-exception')
void notifyStatusListeners(AnimationStatus status) {
final List<AnimationStatusListener> localListeners = List<AnimationStatusListener>.of(_statusListeners);
final List<AnimationStatusListener> localListeners = _statusListeners.toList(growable: false);
for (final AnimationStatusListener listener in localListeners) {
try {
if (_statusListeners.contains(listener))
......
......@@ -76,6 +76,11 @@ class ObserverList<T> extends Iterable<T> {
@override
bool get isNotEmpty => _list.isNotEmpty;
@override
List<T> toList({bool growable = true}) {
return _list.toList(growable: growable);
}
}
/// A list optimized for the observer pattern, but for larger numbers of observers.
......
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