From 8ef90b864168e0aed97ad17825253f5a43c51ecb Mon Sep 17 00:00:00 2001 From: Alexander Markov Date: Fri, 26 Jun 2020 22:51:08 +0000 Subject: [PATCH] [benchmarks] Remove expensive Iterable.cast from NNBD version of ListCopy benchmark MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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() 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 Reviewed-by: RĂ©gis Crelier Reviewed-by: William Hesse --- benchmarks/ListCopy/dart/ListCopy.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/ListCopy/dart/ListCopy.dart b/benchmarks/ListCopy/dart/ListCopy.dart index 1091c930307..74b95e1f3d7 100644 --- a/benchmarks/ListCopy/dart/ListCopy.dart +++ b/benchmarks/ListCopy/dart/ListCopy.dart @@ -131,7 +131,7 @@ List makeBenchmarks(int length) => [ output = [...input]; }), Benchmark('spread.int', length, () { - output = [...input.cast()]; + output = [...input as dynamic]; }), ];