am 6e2ba9b0: Remove unnecessary maxProximityCharsSize

# Via Ken Wakasa
* commit '6e2ba9b01e61d214e8d6fad8d7093a80a97dd243':
  Remove unnecessary maxProximityCharsSize
main
Ken Wakasa 2013-01-30 02:29:10 -08:00 committed by Android Git Automerger
commit c741d23f81
3 changed files with 21 additions and 27 deletions

View File

@ -110,8 +110,8 @@ bool ProximityInfo::hasSpaceProximity(const int x, const int y) const {
return false;
}
const int startIndex = ProximityInfoUtils::getStartIndexFromCoordinates(
MAX_PROXIMITY_CHARS_SIZE, x, y, CELL_HEIGHT, CELL_WIDTH, GRID_WIDTH);
const int startIndex = ProximityInfoUtils::getStartIndexFromCoordinates(x, y,
CELL_HEIGHT, CELL_WIDTH, GRID_WIDTH);
if (DEBUG_PROXIMITY_INFO) {
AKLOGI("hasSpaceProximity: index %d, %d, %d", startIndex, x, y);
}

View File

@ -73,9 +73,8 @@ class ProximityInfo {
const int *const inputYCoordinates, const int inputSize, int *allInputCodes) const {
ProximityInfoUtils::initializeProximities(inputCodes, inputXCoordinates, inputYCoordinates,
inputSize, mKeyXCoordinates, mKeyYCoordinates, mKeyWidths, mKeyHeights,
mProximityCharsArray, MAX_PROXIMITY_CHARS_SIZE, CELL_HEIGHT, CELL_WIDTH,
GRID_WIDTH, MOST_COMMON_KEY_WIDTH, KEY_COUNT, mLocaleStr, &mCodeToKeyMap,
allInputCodes);
mProximityCharsArray, CELL_HEIGHT, CELL_WIDTH, GRID_WIDTH, MOST_COMMON_KEY_WIDTH,
KEY_COUNT, mLocaleStr, &mCodeToKeyMap, allInputCodes);
}
int getKeyIndexOf(const int c) const {

View File

@ -49,9 +49,9 @@ class ProximityInfoUtils {
const int *const inputXCoordinates, const int *const inputYCoordinates,
const int inputSize, const int *const keyXCoordinates,
const int *const keyYCoordinates, const int *const keyWidths, const int *keyHeights,
const int *const proximityCharsArray, const int maxProximityCharsSize,
const int cellHeight, const int cellWidth, const int gridWidth,
const int mostCommonKeyWidth, const int keyCount, const char *const localeStr,
const int *const proximityCharsArray, const int cellHeight, const int cellWidth,
const int gridWidth, const int mostCommonKeyWidth, const int keyCount,
const char *const localeStr,
const hash_map_compat<int, int> *const codeToKeyMap, int *inputProximities) {
// Initialize
// - mInputCodes
@ -63,9 +63,8 @@ class ProximityInfoUtils {
const int y = inputYCoordinates[i];
int *proximities = &inputProximities[i * MAX_PROXIMITY_CHARS_SIZE];
calculateProximities(keyXCoordinates, keyYCoordinates, keyWidths, keyHeights,
proximityCharsArray, maxProximityCharsSize, cellHeight, cellWidth, gridWidth,
mostCommonKeyWidth, keyCount, x, y, primaryKey, localeStr, codeToKeyMap,
proximities);
proximityCharsArray, cellHeight, cellWidth, gridWidth, mostCommonKeyWidth,
keyCount, x, y, primaryKey, localeStr, codeToKeyMap, proximities);
}
if (DEBUG_PROXIMITY_CHARS) {
@ -81,10 +80,9 @@ class ProximityInfoUtils {
}
}
static AK_FORCE_INLINE int getStartIndexFromCoordinates(const int maxProximityCharsSize,
const int x, const int y, const int cellHeight, const int cellWidth,
const int gridWidth) {
return ((y / cellHeight) * gridWidth + (x / cellWidth)) * maxProximityCharsSize;
static AK_FORCE_INLINE int getStartIndexFromCoordinates(const int x, const int y,
const int cellHeight, const int cellWidth, const int gridWidth) {
return ((y / cellHeight) * gridWidth + (x / cellWidth)) * MAX_PROXIMITY_CHARS_SIZE;
}
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;
}
static void calculateProximities(
const int *const keyXCoordinates, const int *const keyYCoordinates,
const int *const keyWidths, const int *keyHeights,
const int *const proximityCharsArray,
const int maxProximityCharsSize, const int cellHeight, const int cellWidth,
static void calculateProximities(const int *const keyXCoordinates,
const int *const keyYCoordinates, const int *const keyWidths, const int *keyHeights,
const int *const proximityCharsArray, const int cellHeight, const int cellWidth,
const int gridWidth, const int mostCommonKeyWidth, const int keyCount,
const int x, const int y, const int primaryKey, const char *const localeStr,
const hash_map_compat<int, int> *const codeToKeyMap, int *proximities) {
const int mostCommonKeyWidthSquare = mostCommonKeyWidth * mostCommonKeyWidth;
int insertPos = 0;
proximities[insertPos++] = primaryKey;
const int startIndex = getStartIndexFromCoordinates(
maxProximityCharsSize, x, y, cellHeight, cellWidth, gridWidth);
const int startIndex = getStartIndexFromCoordinates(x, y, cellHeight, cellWidth, gridWidth);
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];
if (c < KEYCODE_SPACE || c == primaryKey) {
continue;
@ -179,7 +174,7 @@ class ProximityInfoUtils {
keyWidths, keyHeights, keyIndex, x, y);
if (onKey || distance < mostCommonKeyWidthSquare) {
proximities[insertPos++] = c;
if (insertPos >= maxProximityCharsSize) {
if (insertPos >= MAX_PROXIMITY_CHARS_SIZE) {
if (DEBUG_DICT) {
ASSERT(false);
}
@ -191,7 +186,7 @@ class ProximityInfoUtils {
AdditionalProximityChars::getAdditionalCharsSize(localeStr, primaryKey);
if (additionalProximitySize > 0) {
proximities[insertPos++] = ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE;
if (insertPos >= maxProximityCharsSize) {
if (insertPos >= MAX_PROXIMITY_CHARS_SIZE) {
if (DEBUG_DICT) {
ASSERT(false);
}
@ -212,7 +207,7 @@ class ProximityInfoUtils {
continue;
}
proximities[insertPos++] = ac;
if (insertPos >= maxProximityCharsSize) {
if (insertPos >= MAX_PROXIMITY_CHARS_SIZE) {
if (DEBUG_DICT) {
ASSERT(false);
}
@ -222,7 +217,7 @@ class ProximityInfoUtils {
}
}
// 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;
}
}