aboutsummaryrefslogtreecommitdiffstats
path: root/native/jni/src/proximity_info_state.cpp
diff options
context:
space:
mode:
authorSatoshi Kataoka <satok@google.com>2013-01-15 19:16:38 +0900
committerSatoshi Kataoka <satok@google.com>2013-01-15 19:45:49 +0900
commita9763f93d76f97b9c6ed7dd1369a4d8cb016f06f (patch)
tree4d8e16c6a6d11c84e6322c2edf130d5373462984 /native/jni/src/proximity_info_state.cpp
parent6cee61deebd0ca2b85054ccc239523d1e5fdfab1 (diff)
downloadlatinime-a9763f93d76f97b9c6ed7dd1369a4d8cb016f06f.tar.gz
latinime-a9763f93d76f97b9c6ed7dd1369a4d8cb016f06f.tar.xz
latinime-a9763f93d76f97b9c6ed7dd1369a4d8cb016f06f.zip
refactor distance cache
Change-Id: I21b54b356641a63d7be17fd34b9ede7a63ec738a
Diffstat (limited to 'native/jni/src/proximity_info_state.cpp')
-rw-r--r--native/jni/src/proximity_info_state.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/native/jni/src/proximity_info_state.cpp b/native/jni/src/proximity_info_state.cpp
index d0cc4acc2..aa029297e 100644
--- a/native/jni/src/proximity_info_state.cpp
+++ b/native/jni/src/proximity_info_state.cpp
@@ -101,7 +101,7 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
mTimes.clear();
mInputIndice.clear();
mLengthCache.clear();
- mDistanceCache.clear();
+ mDistanceCache_G.clear();
mNearKeysVector.clear();
mSearchKeysVector.clear();
mSpeedRates.clear();
@@ -210,7 +210,7 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
const int keyCount = mProximityInfo->getKeyCount();
mNearKeysVector.resize(mSampledInputSize);
mSearchKeysVector.resize(mSampledInputSize);
- mDistanceCache.resize(mSampledInputSize * keyCount);
+ mDistanceCache_G.resize(mSampledInputSize * keyCount);
for (int i = lastSavedInputSize; i < mSampledInputSize; ++i) {
mNearKeysVector[i].reset();
mSearchKeysVector[i].reset();
@@ -221,7 +221,7 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
const int y = mSampledInputYs[i];
const float normalizedSquaredDistance =
mProximityInfo->getNormalizedSquaredDistanceFromCenterFloatG(k, x, y);
- mDistanceCache[index] = normalizedSquaredDistance;
+ mDistanceCache_G[index] = normalizedSquaredDistance;
if (normalizedSquaredDistance < NEAR_KEY_NORMALIZED_SQUARED_THRESHOLD) {
mNearKeysVector[i][k] = true;
}
@@ -686,7 +686,7 @@ float ProximityInfoState::getPointToKeyLength(
const int keyId = mProximityInfo->getKeyIndexOf(codePoint);
if (keyId != NOT_AN_INDEX) {
const int index = inputIndex * mProximityInfo->getKeyCount() + keyId;
- return min(mDistanceCache[index] * scale, mMaxPointToKeyLength);
+ return min(mDistanceCache_G[index] * scale, mMaxPointToKeyLength);
}
if (isSkippableCodePoint(codePoint)) {
return 0.0f;
@@ -695,7 +695,7 @@ float ProximityInfoState::getPointToKeyLength(
return MAX_POINT_TO_KEY_LENGTH;
}
-float ProximityInfoState::getPointToKeyLength(const int inputIndex, const int codePoint) const {
+float ProximityInfoState::getPointToKeyLength_G(const int inputIndex, const int codePoint) const {
return getPointToKeyLength(inputIndex, codePoint, 1.0f);
}
@@ -706,7 +706,7 @@ float ProximityInfoState::getPointToKeyByIdLength(
const int inputIndex, const int keyId, const float scale) const {
if (keyId != NOT_AN_INDEX) {
const int index = inputIndex * mProximityInfo->getKeyCount() + keyId;
- return min(mDistanceCache[index] * scale, mMaxPointToKeyLength);
+ return min(mDistanceCache_G[index] * scale, mMaxPointToKeyLength);
}
// If the char is not a key on the keyboard then return the max length.
return static_cast<float>(MAX_POINT_TO_KEY_LENGTH);