Skip to content

Commit f530bae

Browse files
refactor(benchmark): Replace getNextList method with a getter to follow Effective Dart
I removed the leading "get" from method names and updated call sites so the API doesn't start method names with "get". This change follows the Effective Dart guideline: avoid starting a method name with get — see https://dart.dev/effective-dart/design#avoid-starting-a-method-name-with-get
1 parent 4073118 commit f530bae

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

pkgs/collection/benchmark/sort_benchmark.dart

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ abstract class SortBenchmarkBase extends BenchmarkBase {
3030

3131
SortBenchmarkBase(super.name, this.datasets);
3232

33-
List<int> getNextList() {
34-
// Cloning the list is crucial so each run sorts an unsorted list.
35-
return List<int>.from(datasets[_iteration++ % datasets.length]);
36-
}
33+
List<int> get nextList =>
34+
List<int>.from(datasets[_iteration++ % datasets.length]);
3735

3836
void updateChecksum(List<int> list) {
3937
// A simple checksum to ensure the list is used and not optimized away.
@@ -55,7 +53,7 @@ class QuickSortBaselineRandomBenchmark extends SortBenchmarkBase {
5553
: super('Baseline.Random', dataset_generator.random);
5654
@override
5755
void performSort() {
58-
final list = getNextList();
56+
final list = nextList;
5957
quickSortBaseline(list, (a, b) => a.compareTo(b));
6058
updateChecksum(list);
6159
}
@@ -66,7 +64,7 @@ class QuickSortBaselineSortedBenchmark extends SortBenchmarkBase {
6664
: super('Baseline.Sorted', dataset_generator.sorted);
6765
@override
6866
void performSort() {
69-
final list = getNextList();
67+
final list = nextList;
7068
quickSortBaseline(list, (a, b) => a.compareTo(b));
7169
updateChecksum(list);
7270
}
@@ -77,7 +75,7 @@ class QuickSortBaselineReverseBenchmark extends SortBenchmarkBase {
7775
: super('Baseline.Reverse', dataset_generator.reverse);
7876
@override
7977
void performSort() {
80-
final list = getNextList();
78+
final list = nextList;
8179
quickSortBaseline(list, (a, b) => a.compareTo(b));
8280
updateChecksum(list);
8381
}
@@ -88,7 +86,7 @@ class QuickSortBaselineFewUniqueBenchmark extends SortBenchmarkBase {
8886
: super('Baseline.FewUnique', dataset_generator.fewUnique);
8987
@override
9088
void performSort() {
91-
final list = getNextList();
89+
final list = nextList;
9290
quickSortBaseline(list, (a, b) => a.compareTo(b));
9391
updateChecksum(list);
9492
}
@@ -99,7 +97,7 @@ class QuickSortBaselinePathologicalBenchmark extends SortBenchmarkBase {
9997
: super('Baseline.Pathological', dataset_generator.pathological);
10098
@override
10199
void performSort() {
102-
final list = getNextList();
100+
final list = nextList;
103101
quickSortBaseline(list, (a, b) => a.compareTo(b));
104102
updateChecksum(list);
105103
}
@@ -111,7 +109,7 @@ class PdqSortEnhancementRandomBenchmark extends SortBenchmarkBase {
111109
: super('Enhancement.Random', dataset_generator.random);
112110
@override
113111
void performSort() {
114-
final list = getNextList();
112+
final list = nextList;
115113
quickSort(list, (a, b) => a.compareTo(b));
116114
updateChecksum(list);
117115
}
@@ -122,7 +120,7 @@ class PdqSortEnhancementSortedBenchmark extends SortBenchmarkBase {
122120
: super('Enhancement.Sorted', dataset_generator.sorted);
123121
@override
124122
void performSort() {
125-
final list = getNextList();
123+
final list = nextList;
126124
quickSort(list, (a, b) => a.compareTo(b));
127125
updateChecksum(list);
128126
}
@@ -133,7 +131,7 @@ class PdqSortEnhancementReverseBenchmark extends SortBenchmarkBase {
133131
: super('Enhancement.Reverse', dataset_generator.reverse);
134132
@override
135133
void performSort() {
136-
final list = getNextList();
134+
final list = nextList;
137135
quickSort(list, (a, b) => a.compareTo(b));
138136
updateChecksum(list);
139137
}
@@ -144,7 +142,7 @@ class PdqSortEnhancementFewUniqueBenchmark extends SortBenchmarkBase {
144142
: super('Enhancement.FewUnique', dataset_generator.fewUnique);
145143
@override
146144
void performSort() {
147-
final list = getNextList();
145+
final list = nextList;
148146
quickSort(list, (a, b) => a.compareTo(b));
149147
updateChecksum(list);
150148
}
@@ -155,7 +153,7 @@ class PdqSortEnhancementPathologicalBenchmark extends SortBenchmarkBase {
155153
: super('Enhancement.Pathological', dataset_generator.pathological);
156154
@override
157155
void performSort() {
158-
final list = getNextList();
156+
final list = nextList;
159157
quickSort(list, (a, b) => a.compareTo(b));
160158
updateChecksum(list);
161159
}

0 commit comments

Comments
 (0)