@@ -10,7 +10,7 @@ import 'package:benchmark_harness/benchmark_harness.dart';
10
10
//
11
11
// The set of benchmarks compares the cost of reading typed data lists, mostly
12
12
// different kinds of [Uint8List] - plain [Uint8List]s, [Uint8List]s that are
13
- // views of another [Uint8List], and [UnmodifiableUint8ListView]s of these.
13
+ // views of another [Uint8List], and unmodifiable views of these.
14
14
//
15
15
// The benchmarks do not try to use external [Uint8List]s, since this is does
16
16
// not easily translate to the web.
@@ -168,15 +168,15 @@ class Polymorphic1 extends Base {
168
168
}
169
169
170
170
/// [Polymorphic2] calls `sum` with a flat allocated [Uint8List] and an
171
- /// [UnmodifiableUint8ListView] of the same list. This mildly polymorphic, so
171
+ /// unmodifiable view of the same list. This mildly polymorphic, so
172
172
/// there is the possibility that `sum` runs slower than [Monomorphic.sum] .
173
173
///
174
174
/// The workload can be varied:
175
175
///
176
- /// - `view` measures the cost of accessing the [UnmodifiableUint8ListView] .
176
+ /// - `view` measures the cost of accessing the unmodifiable view .
177
177
///
178
178
/// - `array` measures the cost of accessing a simple [Uint8List] using the
179
- /// same code that can also access an [UnmodifiableUint8ListView ].
179
+ /// same code that can also access an unmodifiable view of a [Uint8List ].
180
180
class Polymorphic2 extends Base {
181
181
final List <int > data1;
182
182
final List <int > data2;
@@ -185,7 +185,7 @@ class Polymorphic2 extends Base {
185
185
186
186
factory Polymorphic2 (int n, String variant) {
187
187
final data1 = Uint8List (n)..setToOnes ();
188
- final data2 = UnmodifiableUint8ListView ( data1);
188
+ final data2 = data1. asUnmodifiableView ( );
189
189
if (variant == 'array' ) return Polymorphic2 ._(n, variant, data1, data1);
190
190
if (variant == 'view' ) return Polymorphic2 ._(n, variant, data2, data2);
191
191
throw UnimplementedError ('No variant "$variant "' );
@@ -219,7 +219,7 @@ class Polymorphic2 extends Base {
219
219
}
220
220
221
221
/// [Polymorphic3] is similar to [Polymorphic2] , but the 'other' list is an
222
- /// [UnmodifiableUint8ListView] of a modifiable view.
222
+ /// unmodifiable view of a modifiable view.
223
223
class Polymorphic3 extends Base {
224
224
final List <int > data1;
225
225
final List <int > data2;
@@ -228,7 +228,7 @@ class Polymorphic3 extends Base {
228
228
factory Polymorphic3 (int n, String variant) {
229
229
final data1 = Uint8List (n)..setToOnes ();
230
230
final view1 = Uint8List .sublistView (Uint8List (n + 1 )..setToOnes (), 1 );
231
- final data2 = UnmodifiableUint8ListView ( view1);
231
+ final data2 = view1. asUnmodifiableView ( );
232
232
if (variant == 'array' ) return Polymorphic3 ._(n, variant, data1, data1);
233
233
if (variant == 'view' ) return Polymorphic3 ._(n, variant, data2, data2);
234
234
throw UnimplementedError ('No variant "$variant "' );
@@ -261,7 +261,7 @@ class Polymorphic3 extends Base {
261
261
}
262
262
}
263
263
264
- /// [Polymorphic4] stacks [UnmodifiableUint8ListView] s five levels deep.
264
+ /// [Polymorphic4] stacks unmodifiable views five levels deep.
265
265
class Polymorphic4 extends Base {
266
266
final List <int > data1;
267
267
final List <int > data2;
@@ -270,11 +270,11 @@ class Polymorphic4 extends Base {
270
270
271
271
factory Polymorphic4 (int n, String variant) {
272
272
final data1 = Uint8List (n)..setToOnes ();
273
- var data2 = UnmodifiableUint8ListView ( data1);
274
- data2 = UnmodifiableUint8ListView ( data2);
275
- data2 = UnmodifiableUint8ListView ( data2);
276
- data2 = UnmodifiableUint8ListView ( data2);
277
- data2 = UnmodifiableUint8ListView ( data2);
273
+ var data2 = data1. asUnmodifiableView ( );
274
+ data2 = data2. asUnmodifiableView ( );
275
+ data2 = data2. asUnmodifiableView ( );
276
+ data2 = data2. asUnmodifiableView ( );
277
+ data2 = data2. asUnmodifiableView ( );
278
278
if (variant == 'array' ) return Polymorphic4 ._(n, variant, data1, data1);
279
279
if (variant == 'view' ) return Polymorphic4 ._(n, variant, data2, data2);
280
280
throw UnimplementedError ('No variant "$variant "' );
@@ -342,11 +342,11 @@ class Polymorphic5 extends Base {
342
342
final data4 = Int8List (n)..setToOnes ();
343
343
final data5 = Int16List (n)..setToOnes ();
344
344
345
- final data6 = UnmodifiableUint8ListView ( data1);
346
- final data7 = UnmodifiableUint16ListView ( data2);
347
- final data8 = UnmodifiableUint32ListView ( data3);
348
- final data9 = UnmodifiableInt8ListView ( data4);
349
- final data10 = UnmodifiableInt16ListView ( data5);
345
+ final data6 = data1. asUnmodifiableView ( );
346
+ final data7 = data2. asUnmodifiableView ( );
347
+ final data8 = data3. asUnmodifiableView ( );
348
+ final data9 = data4. asUnmodifiableView ( );
349
+ final data10 = data5. asUnmodifiableView ( );
350
350
351
351
if (variant == 'array' ) {
352
352
return Polymorphic5 ._(n, variant, data1, data1, data1, data1, data1,
0 commit comments