Skip to content

Commit e7777d9

Browse files
authored
chore: Expunge codebase of unholy abbreviations (idx) (#3677)
Expunge codebase of unholy abbreviations (idx). This prevents further misery to be latched upon @spydon
1 parent b79fee0 commit e7777d9

12 files changed

Lines changed: 39 additions & 37 deletions

File tree

examples/lib/stories/components/look_at_example.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class _TapWorld extends World
7474
paint: BasicPalette.black.paint(),
7575
);
7676

77-
int _currentFlipIdx = 0;
77+
int _currentFlipIndex = 0;
7878
final _flips = [
7979
(Vector2(1, 1), Vector2(1, 1)),
8080
(Vector2(1, 1), Vector2(1, -1)),
@@ -111,8 +111,8 @@ class _TapWorld extends World
111111
}
112112

113113
void _cycleFlips() {
114-
_currentFlipIdx = (_currentFlipIdx + 1) % _flips.length;
115-
final nextFlip = _flips[_currentFlipIdx];
114+
_currentFlipIndex = (_currentFlipIndex + 1) % _flips.length;
115+
final nextFlip = _flips[_currentFlipIndex];
116116
for (final parent in game._choppers) {
117117
parent.scale = nextFlip.$1;
118118
parent.chopper.scale = nextFlip.$2;

packages/flame/benchmark/update_components_benchmark.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class UpdateComponentsBenchmark extends AsyncBenchmarkBase {
4747

4848
@override
4949
Future<void> run() async {
50-
for (final (idx, dt) in _dts.indexed) {
51-
if (_inputTicks.contains(idx)) {
50+
for (final (index, dt) in _dts.indexed) {
51+
if (_inputTicks.contains(index)) {
5252
_components[random.nextInt(_amountComponents)].input(
5353
xDirection: random.nextInt(3) - 1,
5454
doJump: random.nextBool(),

packages/flame/lib/src/components/core/component_key.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:flame/game.dart';
22
import 'package:meta/meta.dart';
33

4-
var _idx = 0;
4+
var _index = 0;
55

66
/// A key that can be used to identify a component and later
77
/// retrieve it from its [FlameGame] ancestor.
@@ -12,7 +12,7 @@ class ComponentKey {
1212

1313
/// Creates a key that is unique, each instance will only
1414
/// be equal to itself.
15-
ComponentKey.unique() : _internalHash = _idx++;
15+
ComponentKey.unique() : _internalHash = _index++;
1616

1717
final int _internalHash;
1818

packages/flame/test/components/position_component_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ void main() {
10791079
-4, -3, -2, -1, 0, 1, 2, 3, //
10801080
0, 1, 2, 3, 4, -3, -2, -1, //
10811081
];
1082-
var idx = 0;
1082+
var index = 0;
10831083
for (final flip in flips) {
10841084
wrapper.scale = flip.$1;
10851085
child.scale = flip.$2;
@@ -1088,7 +1088,7 @@ void main() {
10881088
final target = Vector2(0, -1)..rotate(angle);
10891089
expectDouble(
10901090
child.angleTo(target),
1091-
expectedResults[idx++] * tau / 8,
1091+
expectedResults[index++] * tau / 8,
10921092
epsilon: 1e-10,
10931093
reason: 'angleTo with flip $flip, angle $angle, target $target',
10941094
);

packages/flame/test/widgets/sprite_animation_widget_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Future<void> main() async {
9090
animationTicker1.onStart = () => animation1Started = true;
9191
animationTicker2.onStart = () => animation2Started = true;
9292

93-
for (var idx = 0; idx < executionCount; idx++) {
93+
for (var index = 0; index < executionCount; index++) {
9494
animation1Started = false;
9595
animation2Started = false;
9696

packages/flame_3d/lib/src/graphics/joints_info.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class JointsInfo {
77
/// Joints for the current surface
88
List<Matrix4> jointTransforms = [];
99

10-
void setSurface(int surfaceIdx) {
11-
jointTransforms = jointTransformsPerSurface[surfaceIdx] ?? [];
10+
void setSurface(int surfaceIndex) {
11+
jointTransforms = jointTransformsPerSurface[surfaceIndex] ?? [];
1212
}
1313
}

packages/flame_3d/lib/src/parser/gltf/animation.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ class Animation extends GltfNode {
7878
}
7979
as AnimationSpline;
8080

81-
final nodeIdx = channel.target.node.index;
82-
(controllers[nodeIdx] ??= []).add(
81+
final nodeIndex = channel.target.node.index;
82+
(controllers[nodeIndex] ??= []).add(
8383
AnimationController(
8484
animation: spline,
8585
),

packages/flame_3d/lib/src/resources/shader/uniform_array.dart

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'dart:typed_data';
44
import 'package:flame_3d/graphics.dart';
55
import 'package:flame_3d/resources.dart';
66

7-
typedef UniformArrayKey = ({int idx, String field});
7+
typedef UniformArrayKey = ({int index, String field});
88

99
/// {@template uniform_value}
1010
/// Instance of a uniform array. Represented by a [ByteBuffer].
@@ -36,18 +36,20 @@ class UniformArray extends UniformInstance<UniformArrayKey, ByteBuffer> {
3636
return Float32List.fromList(data).buffer;
3737
}
3838

39-
Map<int, ({int hash, List<double> data})> _get(int idx) {
40-
while (idx >= _storage.length) {
39+
Map<int, ({int hash, List<double> data})> _get(int index) {
40+
while (index >= _storage.length) {
4141
_storage.add(HashMap());
4242
}
43-
return _storage[idx];
43+
return _storage[index];
4444
}
4545

46-
List<double>? get(int idx, String key) => _get(idx)[slot.indexOf(key)]?.data;
46+
List<double>? get(int index, String key) {
47+
return _get(index)[slot.indexOf(key)]?.data;
48+
}
4749

4850
@override
4951
void set(UniformArrayKey key, ByteBuffer buffer) {
50-
final storage = _get(key.idx);
52+
final storage = _get(key.index);
5153
final index = slot.indexOf(key.field);
5254

5355
// Ensure that we are only setting new data if the hash has changed.
@@ -65,15 +67,15 @@ class UniformArray extends UniformInstance<UniformArrayKey, ByteBuffer> {
6567
}
6668

6769
@override
68-
UniformArrayKey makeKey(int? idx, String? field) {
69-
if (idx == null) {
70-
throw StateError('idx is required for ${slot.name}');
70+
UniformArrayKey makeKey(int? index, String? field) {
71+
if (index == null) {
72+
throw StateError('index is required for ${slot.name}');
7173
}
7274
if (field == null) {
7375
throw StateError('field is required for ${slot.name}');
7476
}
7577

76-
return (idx: idx, field: field);
78+
return (index: index, field: field);
7779
}
7880

7981
@override

packages/flame_3d/lib/src/resources/shader/uniform_instance.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ abstract class UniformInstance<K, T> extends Resource<T?> {
1616

1717
void set(K key, T value);
1818

19-
K makeKey(int? idx, String? field);
19+
K makeKey(int? index, String? field);
2020
}

packages/flame_3d/lib/src/resources/shader/uniform_sampler.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ class UniformSampler extends UniformInstance<void, Texture> {
2525
Texture createResource() => texture!;
2626

2727
@override
28-
void makeKey(int? idx, String? field) {}
28+
void makeKey(int? index, String? field) {}
2929
}

0 commit comments

Comments
 (0)