Vyacheslav Egorov 8130029374
Use persistent hash map to store _inheritedWidgets (#107068)
* Use persistent hash map to store _inheritedWidgets

Instead of using a HashMap and copying it down the tree
which leads to quadratic time and space complexity
use a persistent data structure which can amortize
the cost by sharing parts of the structure.

The data shows HAMT based PersistentHashMap to be
5-10x faster for building _inheritedWidgets and
considerably more space effecient (e.g. bringing
amount of memory allocated when constructing
_inheritedWidgets in a tree with 150 InheritedWidget
down to 70Kb from 970Kb).

PersistentHashMap is slower than HashMap for
access: 2-3x in relative terms, but in absolute
terms we are only talking about ~0.2ns slow down
per access and various app benchmarks we run have
have not revealed any significant regressions.
2022-07-19 21:45:26 -07:00

47 lines
1.5 KiB
Dart

// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// Core Flutter framework primitives.
///
/// The features defined in this library are the lowest-level utility
/// classes and functions used by all the other layers of the Flutter
/// framework.
library foundation;
export 'package:meta/meta.dart' show
factory,
immutable,
mustCallSuper,
nonVirtual,
optionalTypeArgs,
protected,
required,
visibleForTesting;
export 'src/foundation/annotations.dart';
export 'src/foundation/assertions.dart';
export 'src/foundation/basic_types.dart';
export 'src/foundation/binding.dart';
export 'src/foundation/bitfield.dart';
export 'src/foundation/change_notifier.dart';
export 'src/foundation/collections.dart';
export 'src/foundation/consolidate_response.dart';
export 'src/foundation/constants.dart';
export 'src/foundation/debug.dart';
export 'src/foundation/diagnostics.dart';
export 'src/foundation/isolates.dart';
export 'src/foundation/key.dart';
export 'src/foundation/licenses.dart';
export 'src/foundation/math.dart';
export 'src/foundation/node.dart';
export 'src/foundation/object.dart';
export 'src/foundation/observer_list.dart';
export 'src/foundation/persistent_hash_map.dart';
export 'src/foundation/platform.dart';
export 'src/foundation/print.dart';
export 'src/foundation/serialization.dart';
export 'src/foundation/stack_frame.dart';
export 'src/foundation/synchronous_future.dart';
export 'src/foundation/unicode.dart';