[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:
Alexander Markov 2020-06-26 22:51:08 +00:00 committed by commit-bot@chromium.org
parent 7fc61e77e2
commit 8ef90b8641

View file

@ -131,7 +131,7 @@ List<Benchmark> makeBenchmarks(int length) => [
output = <num>[...input];
}),
Benchmark('spread.int', length, () {
output = <int>[...input.cast<int>()];
output = <int>[...input as dynamic];
}),
];