mirror of
https://github.com/flutter/flutter
synced 2024-08-25 02:46:31 +00:00
Use inlining annotations on important methods for all targets (#143923)
This commit is contained in:
parent
44e440ae9d
commit
b09ca497bb
|
@ -65,7 +65,9 @@ abstract class _TrieNode {
|
||||||
static const int hashBitsPerLevel = 5;
|
static const int hashBitsPerLevel = 5;
|
||||||
static const int hashBitsPerLevelMask = (1 << hashBitsPerLevel) - 1;
|
static const int hashBitsPerLevelMask = (1 << hashBitsPerLevel) - 1;
|
||||||
|
|
||||||
|
@pragma('dart2js:tryInline')
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
|
@pragma('wasm:prefer-inline')
|
||||||
static int trieIndex(int hash, int bitIndex) {
|
static int trieIndex(int hash, int bitIndex) {
|
||||||
return (hash >>> bitIndex) & hashBitsPerLevelMask;
|
return (hash >>> bitIndex) & hashBitsPerLevelMask;
|
||||||
}
|
}
|
||||||
|
@ -266,7 +268,9 @@ class _CompressedNode extends _TrieNode {
|
||||||
return _FullNode(nodes);
|
return _FullNode(nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@pragma('dart2js:tryInline')
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
|
@pragma('wasm:prefer-inline')
|
||||||
int _compressedIndex(int bit) {
|
int _compressedIndex(int bit) {
|
||||||
return _bitCount(occupiedIndices & (bit - 1));
|
return _bitCount(occupiedIndices & (bit - 1));
|
||||||
}
|
}
|
||||||
|
@ -351,8 +355,9 @@ class _HashCollisionNode extends _TrieNode {
|
||||||
/// Returns number of bits set in a 32bit integer.
|
/// Returns number of bits set in a 32bit integer.
|
||||||
///
|
///
|
||||||
/// dart2js safe because we work with 32bit integers.
|
/// dart2js safe because we work with 32bit integers.
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@pragma('dart2js:tryInline')
|
@pragma('dart2js:tryInline')
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@pragma('wasm:prefer-inline')
|
||||||
int _bitCount(int n) {
|
int _bitCount(int n) {
|
||||||
assert((n & 0xFFFFFFFF) == n);
|
assert((n & 0xFFFFFFFF) == n);
|
||||||
n = n - ((n >> 1) & 0x55555555);
|
n = n - ((n >> 1) & 0x55555555);
|
||||||
|
@ -367,8 +372,9 @@ int _bitCount(int n) {
|
||||||
///
|
///
|
||||||
/// Caveat: do not replace with List.of or similar methods. They are
|
/// Caveat: do not replace with List.of or similar methods. They are
|
||||||
/// considerably slower.
|
/// considerably slower.
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@pragma('dart2js:tryInline')
|
@pragma('dart2js:tryInline')
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@pragma('wasm:prefer-inline')
|
||||||
List<Object?> _copy(List<Object?> array) {
|
List<Object?> _copy(List<Object?> array) {
|
||||||
final List<Object?> clone = _makeArray(array.length);
|
final List<Object?> clone = _makeArray(array.length);
|
||||||
for (int j = 0; j < array.length; j++) {
|
for (int j = 0; j < array.length; j++) {
|
||||||
|
@ -384,17 +390,19 @@ List<Object?> _copy(List<Object?> array) {
|
||||||
/// (growable array instance pointing to a fixed array instance) and
|
/// (growable array instance pointing to a fixed array instance) and
|
||||||
/// consequently fixed length arrays are faster to allocated, require less
|
/// consequently fixed length arrays are faster to allocated, require less
|
||||||
/// memory and are faster to access (less indirections).
|
/// memory and are faster to access (less indirections).
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@pragma('dart2js:tryInline')
|
@pragma('dart2js:tryInline')
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@pragma('wasm:prefer-inline')
|
||||||
List<Object?> _makeArray(int length) {
|
List<Object?> _makeArray(int length) {
|
||||||
return List<Object?>.filled(length, null);
|
return List<Object?>.filled(length, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This helper method becomes an no-op when compiled with dart2js on
|
/// This helper method becomes an no-op when compiled with dart2js on
|
||||||
/// with high level of optimizations enabled.
|
/// with high level of optimizations enabled.
|
||||||
@pragma('dart2js:tryInline')
|
|
||||||
@pragma('dart2js:as:trust')
|
@pragma('dart2js:as:trust')
|
||||||
|
@pragma('dart2js:tryInline')
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
|
@pragma('wasm:prefer-inline')
|
||||||
T _unsafeCast<T>(Object? o) {
|
T _unsafeCast<T>(Object? o) {
|
||||||
return o as T;
|
return o as T;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1925,7 +1925,9 @@ abstract class RenderObject with DiagnosticableTreeMixin implements HitTestTarge
|
||||||
/// This is useful when you have to temporarily clear that variable to
|
/// This is useful when you have to temporarily clear that variable to
|
||||||
/// disable some false-positive checks, such as when computing toStringDeep
|
/// disable some false-positive checks, such as when computing toStringDeep
|
||||||
/// or using custom trees.
|
/// or using custom trees.
|
||||||
|
@pragma('dart2js:tryInline')
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
|
@pragma('wasm:prefer-inline')
|
||||||
static T _withDebugActiveLayoutCleared<T>(T Function() inner) {
|
static T _withDebugActiveLayoutCleared<T>(T Function() inner) {
|
||||||
RenderObject? debugPreviousActiveLayout;
|
RenderObject? debugPreviousActiveLayout;
|
||||||
assert(() {
|
assert(() {
|
||||||
|
|
|
@ -3763,7 +3763,9 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
|
||||||
///
|
///
|
||||||
/// See the [RenderObjectElement] documentation for more information on slots.
|
/// See the [RenderObjectElement] documentation for more information on slots.
|
||||||
@protected
|
@protected
|
||||||
|
@pragma('dart2js:tryInline')
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
|
@pragma('wasm:prefer-inline')
|
||||||
Element? updateChild(Element? child, Widget? newWidget, Object? newSlot) {
|
Element? updateChild(Element? child, Widget? newWidget, Object? newSlot) {
|
||||||
if (newWidget == null) {
|
if (newWidget == null) {
|
||||||
if (child != null) {
|
if (child != null) {
|
||||||
|
@ -4285,7 +4287,9 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
|
||||||
/// The element returned by this function will already have been mounted and
|
/// The element returned by this function will already have been mounted and
|
||||||
/// will be in the "active" lifecycle state.
|
/// will be in the "active" lifecycle state.
|
||||||
@protected
|
@protected
|
||||||
|
@pragma('dart2js:tryInline')
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
|
@pragma('wasm:prefer-inline')
|
||||||
Element inflateWidget(Widget newWidget, Object? newSlot) {
|
Element inflateWidget(Widget newWidget, Object? newSlot) {
|
||||||
final bool isTimelineTracked = !kReleaseMode && _isProfileBuildsEnabledFor(newWidget);
|
final bool isTimelineTracked = !kReleaseMode && _isProfileBuildsEnabledFor(newWidget);
|
||||||
if (isTimelineTracked) {
|
if (isTimelineTracked) {
|
||||||
|
@ -5167,7 +5171,9 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
|
||||||
/// Another example is the [AnimatedBuilder.child] property, which allows the
|
/// Another example is the [AnimatedBuilder.child] property, which allows the
|
||||||
/// non-animating parts of a subtree to remain static even as the
|
/// non-animating parts of a subtree to remain static even as the
|
||||||
/// [AnimatedBuilder.builder] callback recreates the other components.
|
/// [AnimatedBuilder.builder] callback recreates the other components.
|
||||||
|
@pragma('dart2js:tryInline')
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
|
@pragma('wasm:prefer-inline')
|
||||||
void rebuild({bool force = false}) {
|
void rebuild({bool force = false}) {
|
||||||
assert(_lifecycleState != _ElementLifecycle.initial);
|
assert(_lifecycleState != _ElementLifecycle.initial);
|
||||||
if (_lifecycleState != _ElementLifecycle.active || (!_dirty && !force)) {
|
if (_lifecycleState != _ElementLifecycle.active || (!_dirty && !force)) {
|
||||||
|
@ -6485,7 +6491,9 @@ abstract class RenderObjectElement extends Element {
|
||||||
_performRebuild(); // calls widget.updateRenderObject()
|
_performRebuild(); // calls widget.updateRenderObject()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@pragma('dart2js:tryInline')
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
|
@pragma('wasm:prefer-inline')
|
||||||
void _performRebuild() {
|
void _performRebuild() {
|
||||||
assert(() {
|
assert(() {
|
||||||
_debugDoingBuild = true;
|
_debugDoingBuild = true;
|
||||||
|
|
Loading…
Reference in a new issue