Skip to content

Commit 8cfe700

Browse files
committed
Merge pull request #89 from brason/cleanup
Remove unneeded null assignments and use of dynamic
2 parents 81f993f + 886c992 commit 8cfe700

13 files changed

+69
-69
lines changed

lib/src/vector_math/error_helpers.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ part of vector_math;
2323
/// Returns relative error between [calculated] and [correct].
2424
/// The type of [calculated] and [correct] must match and can
2525
/// be any vector, matrix, or quaternion.
26-
double relativeError(dynamic calculated, dynamic correct) {
26+
double relativeError(calculated, correct) {
2727
if (calculated is num && correct is num) {
2828
double diff = (calculated - correct).abs();
2929
return diff / correct;
@@ -34,7 +34,7 @@ double relativeError(dynamic calculated, dynamic correct) {
3434
/// Returns absolute error between [calculated] and [correct].
3535
/// The type of [calculated] and [correct] must match and can
3636
/// be any vector, matrix, or quaternion.
37-
double absoluteError(dynamic calculated, dynamic correct) {
37+
double absoluteError(calculated, correct) {
3838
if (calculated is num && correct is num) {
3939
double diff = (calculated - correct).abs();
4040
return diff;

lib/src/vector_math/matrix2.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class Matrix2 {
235235
}
236236

237237
/// Returns a new vector or matrix by multiplying [this] with [arg].
238-
dynamic operator *(dynamic arg) {
238+
operator *(arg) {
239239
if (arg is double) {
240240
return _mul_scale(arg);
241241
}
@@ -501,7 +501,7 @@ class Matrix2 {
501501
return arg;
502502
}
503503

504-
Vector2 transformed(Vector2 arg, [Vector2 out = null]) {
504+
Vector2 transformed(Vector2 arg, [Vector2 out]) {
505505
if (out == null) {
506506
out = new Vector2.copy(arg);
507507
} else {

lib/src/vector_math/matrix3.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ class Matrix3 {
372372
return r;
373373
}
374374
/// Returns a new vector or matrix by multiplying [this] with [arg].
375-
dynamic operator *(dynamic arg) {
375+
operator *(arg) {
376376
if (arg is double) {
377377
return _mul_scale(arg);
378378
}
@@ -923,7 +923,7 @@ class Matrix3 {
923923
arg.z = z_;
924924
return arg;
925925
}
926-
Vector3 transformed(Vector3 arg, [Vector3 out = null]) {
926+
Vector3 transformed(Vector3 arg, [Vector3 out]) {
927927
if (out == null) {
928928
out = new Vector3.copy(arg);
929929
} else {

lib/src/vector_math/matrix4.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ class Matrix4 {
645645
}
646646

647647
/// Returns a new vector or matrix by multiplying [this] with [arg].
648-
dynamic operator *(dynamic arg) {
648+
operator *(arg) {
649649
if (arg is double) {
650650
return _mul_scale(arg);
651651
}
@@ -706,7 +706,7 @@ class Matrix4 {
706706
}
707707

708708
/// Translate this matrix by a [Vector3], [Vector4], or x,y,z
709-
Matrix4 translate(dynamic x, [double y = 0.0, double z = 0.0]) {
709+
Matrix4 translate(x, [double y = 0.0, double z = 0.0]) {
710710
double tx;
711711
double ty;
712712
double tz;
@@ -850,7 +850,7 @@ class Matrix4 {
850850
}
851851

852852
/// Scale this matrix by a [Vector3], [Vector4], or x,y,z
853-
Matrix4 scale(dynamic x, [double y = null, double z = null]) {
853+
Matrix4 scale(x, [double y, double z]) {
854854
double sx;
855855
double sy;
856856
double sz;
@@ -1782,7 +1782,7 @@ class Matrix4 {
17821782
return arg;
17831783
}
17841784

1785-
Vector3 rotated3(Vector3 arg, [Vector3 out = null]) {
1785+
Vector3 rotated3(Vector3 arg, [Vector3 out]) {
17861786
if (out == null) {
17871787
out = new Vector3.copy(arg);
17881788
} else {
@@ -1810,7 +1810,7 @@ class Matrix4 {
18101810
return arg;
18111811
}
18121812

1813-
Vector3 transformed3(Vector3 arg, [Vector3 out = null]) {
1813+
Vector3 transformed3(Vector3 arg, [Vector3 out]) {
18141814
if (out == null) {
18151815
out = new Vector3.copy(arg);
18161816
} else {
@@ -1843,7 +1843,7 @@ class Matrix4 {
18431843
return arg;
18441844
}
18451845

1846-
Vector4 transformed(Vector4 arg, [Vector4 out = null]) {
1846+
Vector4 transformed(Vector4 arg, [Vector4 out]) {
18471847
if (out == null) {
18481848
out = new Vector4.copy(arg);
18491849
} else {

lib/src/vector_math/noise.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class SimplexNoise {
9797
double _dot4(List<double> g, double x, double y, double z, double w) =>
9898
g[0] * x + g[1] * y + g[2] * z + g[3] * w;
9999

100-
SimplexNoise([Math.Random r = null]) {
100+
SimplexNoise([Math.Random r]) {
101101
if (r == null) {
102102
r = new Math.Random();
103103
}

lib/src/vector_math_64/error_helpers.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ part of vector_math_64;
2323
/// Returns relative error between [calculated] and [correct].
2424
/// The type of [calculated] and [correct] must match and can
2525
/// be any vector, matrix, or quaternion.
26-
double relativeError(dynamic calculated, dynamic correct) {
26+
double relativeError(calculated, correct) {
2727
if (calculated is num && correct is num) {
2828
double diff = (calculated - correct).abs();
2929
return diff / correct;
@@ -34,7 +34,7 @@ double relativeError(dynamic calculated, dynamic correct) {
3434
/// Returns absolute error between [calculated] and [correct].
3535
/// The type of [calculated] and [correct] must match and can
3636
/// be any vector, matrix, or quaternion.
37-
double absoluteError(dynamic calculated, dynamic correct) {
37+
double absoluteError(calculated, correct) {
3838
if (calculated is num && correct is num) {
3939
double diff = (calculated - correct).abs();
4040
return diff;

lib/src/vector_math_64/matrix2.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class Matrix2 {
235235
}
236236

237237
/// Returns a new vector or matrix by multiplying [this] with [arg].
238-
dynamic operator *(dynamic arg) {
238+
operator *(arg) {
239239
if (arg is double) {
240240
return _mul_scale(arg);
241241
}
@@ -501,7 +501,7 @@ class Matrix2 {
501501
return arg;
502502
}
503503

504-
Vector2 transformed(Vector2 arg, [Vector2 out = null]) {
504+
Vector2 transformed(Vector2 arg, [Vector2 out]) {
505505
if (out == null) {
506506
out = new Vector2.copy(arg);
507507
} else {

lib/src/vector_math_64/matrix3.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ class Matrix3 {
372372
return r;
373373
}
374374
/// Returns a new vector or matrix by multiplying [this] with [arg].
375-
dynamic operator *(dynamic arg) {
375+
operator *(arg) {
376376
if (arg is double) {
377377
return _mul_scale(arg);
378378
}
@@ -923,7 +923,7 @@ class Matrix3 {
923923
arg.z = z_;
924924
return arg;
925925
}
926-
Vector3 transformed(Vector3 arg, [Vector3 out = null]) {
926+
Vector3 transformed(Vector3 arg, [Vector3 out]) {
927927
if (out == null) {
928928
out = new Vector3.copy(arg);
929929
} else {

lib/src/vector_math_64/matrix4.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ class Matrix4 {
645645
}
646646

647647
/// Returns a new vector or matrix by multiplying [this] with [arg].
648-
dynamic operator *(dynamic arg) {
648+
operator *(arg) {
649649
if (arg is double) {
650650
return _mul_scale(arg);
651651
}
@@ -706,7 +706,7 @@ class Matrix4 {
706706
}
707707

708708
/// Translate this matrix by a [Vector3], [Vector4], or x,y,z
709-
Matrix4 translate(dynamic x, [double y = 0.0, double z = 0.0]) {
709+
Matrix4 translate(x, [double y = 0.0, double z = 0.0]) {
710710
double tx;
711711
double ty;
712712
double tz;
@@ -850,7 +850,7 @@ class Matrix4 {
850850
}
851851

852852
/// Scale this matrix by a [Vector3], [Vector4], or x,y,z
853-
Matrix4 scale(dynamic x, [double y = null, double z = null]) {
853+
Matrix4 scale(x, [double y, double z]) {
854854
double sx;
855855
double sy;
856856
double sz;
@@ -1782,7 +1782,7 @@ class Matrix4 {
17821782
return arg;
17831783
}
17841784

1785-
Vector3 rotated3(Vector3 arg, [Vector3 out = null]) {
1785+
Vector3 rotated3(Vector3 arg, [Vector3 out]) {
17861786
if (out == null) {
17871787
out = new Vector3.copy(arg);
17881788
} else {
@@ -1810,7 +1810,7 @@ class Matrix4 {
18101810
return arg;
18111811
}
18121812

1813-
Vector3 transformed3(Vector3 arg, [Vector3 out = null]) {
1813+
Vector3 transformed3(Vector3 arg, [Vector3 out]) {
18141814
if (out == null) {
18151815
out = new Vector3.copy(arg);
18161816
} else {
@@ -1843,7 +1843,7 @@ class Matrix4 {
18431843
return arg;
18441844
}
18451845

1846-
Vector4 transformed(Vector4 arg, [Vector4 out = null]) {
1846+
Vector4 transformed(Vector4 arg, [Vector4 out]) {
18471847
if (out == null) {
18481848
out = new Vector4.copy(arg);
18491849
} else {

lib/src/vector_math_64/noise.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class SimplexNoise {
9797
double _dot4(List<double> g, double x, double y, double z, double w) =>
9898
g[0] * x + g[1] * y + g[2] * z + g[3] * w;
9999

100-
SimplexNoise([Math.Random r = null]) {
100+
SimplexNoise([Math.Random r]) {
101101
if (r == null) {
102102
r = new Math.Random();
103103
}

lib/src/vector_math_geometry/mesh_geometry.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class MeshGeometry {
116116

117117
MeshGeometry._internal(
118118
int this.length, int this.stride, List<VertexAttrib> this.attribs,
119-
[Float32List externBuffer = null]) {
119+
[Float32List externBuffer]) {
120120
if (externBuffer == null) {
121121
buffer =
122122
new Float32List((length * stride) ~/ Float32List.BYTES_PER_ELEMENT);
@@ -257,7 +257,7 @@ class MeshGeometry {
257257
return null;
258258
}
259259

260-
dynamic getViewForAttrib(String name) {
260+
VectorList getViewForAttrib(String name) {
261261
for (VertexAttrib attrib in attribs) {
262262
if (attrib.name == name) return attrib.getView(buffer);
263263
}

0 commit comments

Comments
 (0)