Skip to content

Commit 6546d0c

Browse files
Refactor: Improve list creation in _generateSorted
Make the list generation in the `_generateSorted` helper more explicit and performant. - The `base` list is now created with `growable: false` as it's a read-only template. - The final copies are created using `List.of` with an explicit `growable: true` to clearly signal that they are mutable.
1 parent d5d4f52 commit 6546d0c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkgs/collection/benchmark/dataset_generator.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ List<List<int>> _generateRandom() {
2525
}
2626

2727
List<List<int>> _generateSorted() {
28-
final base = List.generate(size, (i) => i);
29-
return List.generate(count, (_) => List<int>.from(base));
28+
final base = List.generate(size, (i) => i, growable: false);
29+
return List.generate(count, (_) => List.of(base, growable: true));
3030
}
3131

3232
List<List<int>> _generateReverse() {

0 commit comments

Comments
 (0)