Refactor, extract common index list incrementation logic into private static method.

This commit is contained in:
Mikael Sand
2017-07-22 16:27:13 +03:00
parent 81044e480a
commit 1e2fd9b102
@@ -256,11 +256,15 @@ class GlyphContext {
} }
} }
float nextX(float glyphWidth) { private static void incrementIndices(ArrayList<Integer> indices, int topIndex) {
for (int index = mXsIndex; index >= 0; index--) { for (int index = topIndex; index >= 0; index--) {
int xIndex = mXIndices.get(index); int xIndex = indices.get(index);
mXIndices.set(index, xIndex + 1); indices.set(index, xIndex + 1);
} }
}
float nextX(float glyphWidth) {
incrementIndices(mXIndices, mXsIndex);
int nextIndex = mXIndex + 1; int nextIndex = mXIndex + 1;
if (nextIndex < mXs.length) { if (nextIndex < mXs.length) {
@@ -276,10 +280,7 @@ class GlyphContext {
} }
float nextY() { float nextY() {
for (int index = mYsIndex; index >= 0; index--) { incrementIndices(mYIndices, mYsIndex);
int yIndex = mYIndices.get(index);
mYIndices.set(index, yIndex + 1);
}
int nextIndex = mYIndex + 1; int nextIndex = mYIndex + 1;
if (nextIndex < mYs.length) { if (nextIndex < mYs.length) {
@@ -293,10 +294,7 @@ class GlyphContext {
} }
float nextRotation() { float nextRotation() {
for (int index = mRsIndex; index >= 0; index--) { incrementIndices(mRIndices, mRsIndex);
int rotationIndex = mRIndices.get(index);
mRIndices.set(index, rotationIndex + 1);
}
mRIndex = Math.min(mRIndex + 1, mRs.length - 1); mRIndex = Math.min(mRIndex + 1, mRs.length - 1);
@@ -306,10 +304,7 @@ class GlyphContext {
} }
float nextDeltaX() { float nextDeltaX() {
for (int index = mdXsIndex; index >= 0; index--) { incrementIndices(mdXIndices, mdXsIndex);
int deltaIndex = mdXIndices.get(index);
mdXIndices.set(index, deltaIndex + 1);
}
int nextIndex = mdXIndex + 1; int nextIndex = mdXIndex + 1;
if (nextIndex < mdXs.length) { if (nextIndex < mdXs.length) {
@@ -322,10 +317,7 @@ class GlyphContext {
} }
float nextDeltaY() { float nextDeltaY() {
for (int index = mdYsIndex; index >= 0; index--) { incrementIndices(mdYIndices, mdYsIndex);
int deltaIndex = mdYIndices.get(index);
mdYIndices.set(index, deltaIndex + 1);
}
int nextIndex = mdYIndex + 1; int nextIndex = mdYIndex + 1;
if (nextIndex < mdYs.length) { if (nextIndex < mdYs.length) {