1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-01 07:14:29 +00:00

[benchmarks] Remove unnecessary utf8.encode() as Uint8List downcast

The return type of `utf8.encode()` was made more precise in [0] (from
`List<int>` to `Uint8List`)

[0] https://dart-review.googlesource.com/c/sdk/+/254903

TEST=ci

Change-Id: I3e578ac8dc5f3f66396cb374e3dcadd989919518
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321860
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
This commit is contained in:
Martin Kustermann 2023-08-21 08:21:37 +00:00 committed by Commit Queue
parent 70310b06d0
commit 4d4a922638
3 changed files with 7 additions and 10 deletions

View File

@ -42,7 +42,7 @@ Uint8List createSampleJson(final size) {
for (int i = 0; i < size; i++) {
map['$i'] = list;
}
return utf8.encode(json.encode(map)) as Uint8List;
return utf8.encode(json.encode(map));
}
class JsonDecodeRequest {
@ -113,7 +113,7 @@ class BenchmarkConfig {
Future<void> main() async {
final jsonString =
File('benchmarks/IsolateJson/dart/sample.json').readAsStringSync();
final json250KB = utf8.encode(jsonString) as Uint8List; // 294356 bytes
final json250KB = utf8.encode(jsonString); // 294356 bytes
final decoded = json.decode(utf8.decode(json250KB));
final decoded1MB = <dynamic, dynamic>{
'1': decoded['1'],
@ -121,14 +121,11 @@ Future<void> main() async {
'3': decoded['1'],
'4': decoded['1'],
};
final json1MB =
utf8.encode(json.encode(decoded1MB)) as Uint8List; // 1177397 bytes
final json1MB = utf8.encode(json.encode(decoded1MB)); // 1177397 bytes
decoded['1'] = (decoded['1'] as List).sublist(0, 200);
final json100KB =
utf8.encode(json.encode(decoded)) as Uint8List; // 104685 bytes
final json100KB = utf8.encode(json.encode(decoded)); // 104685 bytes
decoded['1'] = (decoded['1'] as List).sublist(0, 100);
final json50KB =
utf8.encode(json.encode(decoded)) as Uint8List; // 51760 bytes
final json50KB = utf8.encode(json.encode(decoded)); // 51760 bytes
final configs = <BenchmarkConfig>[
BenchmarkConfig('50KB', json50KB),

View File

@ -39,7 +39,7 @@ class Utf8Decode extends BenchmarkBase {
@override
void setup() {
final Uint8List data = utf8.encode(text) as Uint8List;
final Uint8List data = utf8.encode(text);
if (data.length != 10000) {
throw 'Expected input data of exactly 10000 bytes.';
}

View File

@ -41,7 +41,7 @@ class Utf8Decode extends BenchmarkBase {
@override
void setup() {
final Uint8List data = utf8.encode(text) as Uint8List;
final Uint8List data = utf8.encode(text);
if (data.length != 10000) {
throw 'Expected input data of exactly 10000 bytes.';
}