This issue was originally filed by ir...@google.com
ObservableMap's []= operator should not query the oldValue and length if there are no observers. For small maps, this is not an issue but if the request is being made to populate a huge map, this adds up when there are no observers.
@reflectable void operator []=(K key, V value) {
int len = _map.length;
V oldValue = _map[key];
_map[key] = value;
if (hasObservers) {
if (len != _map.length) {
notifyPropertyChange(#length, len, _map.length);
notifyChange(new MapChangeRecord.insert(key, value));
} else if (oldValue != value) {
notifyChange(new MapChangeRecord(key, oldValue, value));
}
}
}
Originally opened as dart-lang/sdk#17630
This issue was originally filed by ir...@google.com
ObservableMap's []= operator should not query the oldValue and length if there are no observers. For small maps, this is not an issue but if the request is being made to populate a huge map, this adds up when there are no observers.
@reflectable void operator []=(K key, V value) { int len = _map.length; V oldValue = _map[key]; _map[key] = value; if (hasObservers) { if (len != _map.length) { notifyPropertyChange(#length, len, _map.length); notifyChange(new MapChangeRecord.insert(key, value)); } else if (oldValue != value) { notifyChange(new MapChangeRecord(key, oldValue, value)); } } }