Factor out a truncated upper bound

This commit is contained in:
Alexander Ford 2017-06-28 09:03:13 +01:00
parent cd1ed07b8a
commit 2e032bad8c

View file

@ -40,12 +40,14 @@ var Mesh = new Class({
throw new Error('Phaser: Vertex count must match UV count'); throw new Error('Phaser: Vertex count must match UV count');
} }
if (colors.length > 0 && colors.length < ((vertices.length / 2)|0)) var verticesUB = (vertices.length / 2) | 0;
if (colors.length > 0 && colors.length < verticesUB)
{ {
throw new Error('Phaser: Color count must match Vertex count'); throw new Error('Phaser: Color count must match Vertex count');
} }
if (alphas.length > 0 && alphas.length < ((vertices.length / 2)|0)) if (alphas.length > 0 && alphas.length < verticesUB)
{ {
throw new Error('Phaser: Alpha count must match Vertex count'); throw new Error('Phaser: Alpha count must match Vertex count');
} }
@ -54,7 +56,7 @@ var Mesh = new Class({
if (colors.length === 0) if (colors.length === 0)
{ {
for (i = 0; i < (vertices.length / 2)|0; ++i) for (i = 0; i < verticesUB; ++i)
{ {
colors[i] = 0xFFFFFF; colors[i] = 0xFFFFFF;
} }
@ -62,7 +64,7 @@ var Mesh = new Class({
if (alphas.length === 0) if (alphas.length === 0)
{ {
for (i = 0; i < (vertices.length / 2)|0; ++i) for (i = 0; i < verticesUB; ++i)
{ {
alphas[i] = 1.0; alphas[i] = 1.0;
} }