Remove unnecessary maxProximityCharsSize
Change-Id: I8013004c1db2a4133795a0e41edea1a41b770cfd
This commit is contained in:
parent
a47c699faa
commit
6e2ba9b01e
3 changed files with 21 additions and 27 deletions
|
@ -110,8 +110,8 @@ bool ProximityInfo::hasSpaceProximity(const int x, const int y) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int startIndex = ProximityInfoUtils::getStartIndexFromCoordinates(
|
const int startIndex = ProximityInfoUtils::getStartIndexFromCoordinates(x, y,
|
||||||
MAX_PROXIMITY_CHARS_SIZE, x, y, CELL_HEIGHT, CELL_WIDTH, GRID_WIDTH);
|
CELL_HEIGHT, CELL_WIDTH, GRID_WIDTH);
|
||||||
if (DEBUG_PROXIMITY_INFO) {
|
if (DEBUG_PROXIMITY_INFO) {
|
||||||
AKLOGI("hasSpaceProximity: index %d, %d, %d", startIndex, x, y);
|
AKLOGI("hasSpaceProximity: index %d, %d, %d", startIndex, x, y);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,9 +73,8 @@ class ProximityInfo {
|
||||||
const int *const inputYCoordinates, const int inputSize, int *allInputCodes) const {
|
const int *const inputYCoordinates, const int inputSize, int *allInputCodes) const {
|
||||||
ProximityInfoUtils::initializeProximities(inputCodes, inputXCoordinates, inputYCoordinates,
|
ProximityInfoUtils::initializeProximities(inputCodes, inputXCoordinates, inputYCoordinates,
|
||||||
inputSize, mKeyXCoordinates, mKeyYCoordinates, mKeyWidths, mKeyHeights,
|
inputSize, mKeyXCoordinates, mKeyYCoordinates, mKeyWidths, mKeyHeights,
|
||||||
mProximityCharsArray, MAX_PROXIMITY_CHARS_SIZE, CELL_HEIGHT, CELL_WIDTH,
|
mProximityCharsArray, CELL_HEIGHT, CELL_WIDTH, GRID_WIDTH, MOST_COMMON_KEY_WIDTH,
|
||||||
GRID_WIDTH, MOST_COMMON_KEY_WIDTH, KEY_COUNT, mLocaleStr, &mCodeToKeyMap,
|
KEY_COUNT, mLocaleStr, &mCodeToKeyMap, allInputCodes);
|
||||||
allInputCodes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int getKeyIndexOf(const int c) const {
|
int getKeyIndexOf(const int c) const {
|
||||||
|
|
|
@ -49,9 +49,9 @@ class ProximityInfoUtils {
|
||||||
const int *const inputXCoordinates, const int *const inputYCoordinates,
|
const int *const inputXCoordinates, const int *const inputYCoordinates,
|
||||||
const int inputSize, const int *const keyXCoordinates,
|
const int inputSize, const int *const keyXCoordinates,
|
||||||
const int *const keyYCoordinates, const int *const keyWidths, const int *keyHeights,
|
const int *const keyYCoordinates, const int *const keyWidths, const int *keyHeights,
|
||||||
const int *const proximityCharsArray, const int maxProximityCharsSize,
|
const int *const proximityCharsArray, const int cellHeight, const int cellWidth,
|
||||||
const int cellHeight, const int cellWidth, const int gridWidth,
|
const int gridWidth, const int mostCommonKeyWidth, const int keyCount,
|
||||||
const int mostCommonKeyWidth, const int keyCount, const char *const localeStr,
|
const char *const localeStr,
|
||||||
const hash_map_compat<int, int> *const codeToKeyMap, int *inputProximities) {
|
const hash_map_compat<int, int> *const codeToKeyMap, int *inputProximities) {
|
||||||
// Initialize
|
// Initialize
|
||||||
// - mInputCodes
|
// - mInputCodes
|
||||||
|
@ -63,9 +63,8 @@ class ProximityInfoUtils {
|
||||||
const int y = inputYCoordinates[i];
|
const int y = inputYCoordinates[i];
|
||||||
int *proximities = &inputProximities[i * MAX_PROXIMITY_CHARS_SIZE];
|
int *proximities = &inputProximities[i * MAX_PROXIMITY_CHARS_SIZE];
|
||||||
calculateProximities(keyXCoordinates, keyYCoordinates, keyWidths, keyHeights,
|
calculateProximities(keyXCoordinates, keyYCoordinates, keyWidths, keyHeights,
|
||||||
proximityCharsArray, maxProximityCharsSize, cellHeight, cellWidth, gridWidth,
|
proximityCharsArray, cellHeight, cellWidth, gridWidth, mostCommonKeyWidth,
|
||||||
mostCommonKeyWidth, keyCount, x, y, primaryKey, localeStr, codeToKeyMap,
|
keyCount, x, y, primaryKey, localeStr, codeToKeyMap, proximities);
|
||||||
proximities);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG_PROXIMITY_CHARS) {
|
if (DEBUG_PROXIMITY_CHARS) {
|
||||||
|
@ -81,10 +80,9 @@ class ProximityInfoUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static AK_FORCE_INLINE int getStartIndexFromCoordinates(const int maxProximityCharsSize,
|
static AK_FORCE_INLINE int getStartIndexFromCoordinates(const int x, const int y,
|
||||||
const int x, const int y, const int cellHeight, const int cellWidth,
|
const int cellHeight, const int cellWidth, const int gridWidth) {
|
||||||
const int gridWidth) {
|
return ((y / cellHeight) * gridWidth + (x / cellWidth)) * MAX_PROXIMITY_CHARS_SIZE;
|
||||||
return ((y / cellHeight) * gridWidth + (x / cellWidth)) * maxProximityCharsSize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline float getSquaredDistanceFloat(const float x1, const float y1, const float x2,
|
static inline float getSquaredDistanceFloat(const float x1, const float y1, const float x2,
|
||||||
|
@ -153,21 +151,18 @@ class ProximityInfoUtils {
|
||||||
return left < right && top < bottom && x >= left && x < right && y >= top && y < bottom;
|
return left < right && top < bottom && x >= left && x < right && y >= top && y < bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void calculateProximities(
|
static void calculateProximities(const int *const keyXCoordinates,
|
||||||
const int *const keyXCoordinates, const int *const keyYCoordinates,
|
const int *const keyYCoordinates, const int *const keyWidths, const int *keyHeights,
|
||||||
const int *const keyWidths, const int *keyHeights,
|
const int *const proximityCharsArray, const int cellHeight, const int cellWidth,
|
||||||
const int *const proximityCharsArray,
|
|
||||||
const int maxProximityCharsSize, const int cellHeight, const int cellWidth,
|
|
||||||
const int gridWidth, const int mostCommonKeyWidth, const int keyCount,
|
const int gridWidth, const int mostCommonKeyWidth, const int keyCount,
|
||||||
const int x, const int y, const int primaryKey, const char *const localeStr,
|
const int x, const int y, const int primaryKey, const char *const localeStr,
|
||||||
const hash_map_compat<int, int> *const codeToKeyMap, int *proximities) {
|
const hash_map_compat<int, int> *const codeToKeyMap, int *proximities) {
|
||||||
const int mostCommonKeyWidthSquare = mostCommonKeyWidth * mostCommonKeyWidth;
|
const int mostCommonKeyWidthSquare = mostCommonKeyWidth * mostCommonKeyWidth;
|
||||||
int insertPos = 0;
|
int insertPos = 0;
|
||||||
proximities[insertPos++] = primaryKey;
|
proximities[insertPos++] = primaryKey;
|
||||||
const int startIndex = getStartIndexFromCoordinates(
|
const int startIndex = getStartIndexFromCoordinates(x, y, cellHeight, cellWidth, gridWidth);
|
||||||
maxProximityCharsSize, x, y, cellHeight, cellWidth, gridWidth);
|
|
||||||
if (startIndex >= 0) {
|
if (startIndex >= 0) {
|
||||||
for (int i = 0; i < maxProximityCharsSize; ++i) {
|
for (int i = 0; i < MAX_PROXIMITY_CHARS_SIZE; ++i) {
|
||||||
const int c = proximityCharsArray[startIndex + i];
|
const int c = proximityCharsArray[startIndex + i];
|
||||||
if (c < KEYCODE_SPACE || c == primaryKey) {
|
if (c < KEYCODE_SPACE || c == primaryKey) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -179,7 +174,7 @@ class ProximityInfoUtils {
|
||||||
keyWidths, keyHeights, keyIndex, x, y);
|
keyWidths, keyHeights, keyIndex, x, y);
|
||||||
if (onKey || distance < mostCommonKeyWidthSquare) {
|
if (onKey || distance < mostCommonKeyWidthSquare) {
|
||||||
proximities[insertPos++] = c;
|
proximities[insertPos++] = c;
|
||||||
if (insertPos >= maxProximityCharsSize) {
|
if (insertPos >= MAX_PROXIMITY_CHARS_SIZE) {
|
||||||
if (DEBUG_DICT) {
|
if (DEBUG_DICT) {
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
}
|
}
|
||||||
|
@ -191,7 +186,7 @@ class ProximityInfoUtils {
|
||||||
AdditionalProximityChars::getAdditionalCharsSize(localeStr, primaryKey);
|
AdditionalProximityChars::getAdditionalCharsSize(localeStr, primaryKey);
|
||||||
if (additionalProximitySize > 0) {
|
if (additionalProximitySize > 0) {
|
||||||
proximities[insertPos++] = ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE;
|
proximities[insertPos++] = ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE;
|
||||||
if (insertPos >= maxProximityCharsSize) {
|
if (insertPos >= MAX_PROXIMITY_CHARS_SIZE) {
|
||||||
if (DEBUG_DICT) {
|
if (DEBUG_DICT) {
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
}
|
}
|
||||||
|
@ -212,7 +207,7 @@ class ProximityInfoUtils {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
proximities[insertPos++] = ac;
|
proximities[insertPos++] = ac;
|
||||||
if (insertPos >= maxProximityCharsSize) {
|
if (insertPos >= MAX_PROXIMITY_CHARS_SIZE) {
|
||||||
if (DEBUG_DICT) {
|
if (DEBUG_DICT) {
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
}
|
}
|
||||||
|
@ -222,7 +217,7 @@ class ProximityInfoUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add a delimiter for the proximity characters
|
// Add a delimiter for the proximity characters
|
||||||
for (int i = insertPos; i < maxProximityCharsSize; ++i) {
|
for (int i = insertPos; i < MAX_PROXIMITY_CHARS_SIZE; ++i) {
|
||||||
proximities[i] = NOT_A_CODE_POINT;
|
proximities[i] = NOT_A_CODE_POINT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue