mirror of
https://github.com/dart-lang/sdk
synced 2024-09-06 00:59:09 +00:00
[benchmarks] Remove expensive Iterable.cast from NNBD version of ListCopy benchmark
Dart 2 version of this benchmark doesn't have this call. Dart 3 (NNBD) is more strict and allows implicit casts only if casting from dynamic, so it highlights places where types are incompatible. However, Iterable.cast<int>() has a high overhead and it doesn't look like a right way to suppress static type check in this case, as it creates a new Iterable which would additionally cast each element. Simple 'input as dynamic' cast is enough in this case and reflects what was happening in Dart 2 case when types are incompatible. Fixes https://github.com/dart-lang/sdk/issues/42506 Change-Id: I8d83796a53b53e6f567f533f3d5369cd29f6ad97 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152700 Commit-Queue: Alexander Markov <alexmarkov@google.com> Reviewed-by: Régis Crelier <regis@google.com> Reviewed-by: William Hesse <whesse@google.com>
This commit is contained in:
parent
7fc61e77e2
commit
8ef90b8641
|
@ -131,7 +131,7 @@ List<Benchmark> makeBenchmarks(int length) => [
|
||||||
output = <num>[...input];
|
output = <num>[...input];
|
||||||
}),
|
}),
|
||||||
Benchmark('spread.int', length, () {
|
Benchmark('spread.int', length, () {
|
||||||
output = <int>[...input.cast<int>()];
|
output = <int>[...input as dynamic];
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue