aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYusuke Nojima <nojima@google.com>2011-09-14 00:33:20 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-09-14 00:33:20 -0700
commit80f73ccf18b2d88b045f5321990a3fea8d3f1ea4 (patch)
treed535f8108f4990adf5c9936a7a4f66ba55d6e168
parent1586dc6edffc75f3ca5cf9a4b632c0972820dcf8 (diff)
parent032cfeef5abe3a5ddf2e9ef20d834869f8090bee (diff)
downloadlatinime-80f73ccf18b2d88b045f5321990a3fea8d3f1ea4.tar.gz
latinime-80f73ccf18b2d88b045f5321990a3fea8d3f1ea4.tar.xz
latinime-80f73ccf18b2d88b045f5321990a3fea8d3f1ea4.zip
Merge "Delete unused function and add TODO comment for a potential bug."
-rw-r--r--native/src/correction.cpp3
-rw-r--r--native/src/unigram_dictionary.cpp14
2 files changed, 3 insertions, 14 deletions
diff --git a/native/src/correction.cpp b/native/src/correction.cpp
index 5a0e608b8..d5bfed017 100644
--- a/native/src/correction.cpp
+++ b/native/src/correction.cpp
@@ -429,6 +429,9 @@ inline static void multiplyIntCapped(const int multiplier, int *base) {
if (multiplier == 2) {
*base = TWO_31ST_DIV_2 >= temp ? temp << 1 : S_INT_MAX;
} else {
+ // TODO: This overflow check gives a wrong answer when, for example,
+ // temp = 2^16 + 1 and multiplier = 2^17 + 1.
+ // Fix this behavior.
const int tempRetval = temp * multiplier;
*base = tempRetval >= temp ? tempRetval : S_INT_MAX;
}
diff --git a/native/src/unigram_dictionary.cpp b/native/src/unigram_dictionary.cpp
index 4e671a1c4..517dc843e 100644
--- a/native/src/unigram_dictionary.cpp
+++ b/native/src/unigram_dictionary.cpp
@@ -348,20 +348,6 @@ void UnigramDictionary::getSuggestionCandidates() {
}
}
-static const int TWO_31ST_DIV_2 = S_INT_MAX / 2;
-inline static void multiplyIntCapped(const int multiplier, int *base) {
- const int temp = *base;
- if (temp != S_INT_MAX) {
- // Branch if multiplier == 2 for the optimization
- if (multiplier == 2) {
- *base = TWO_31ST_DIV_2 >= temp ? temp << 1 : S_INT_MAX;
- } else {
- const int tempRetval = temp * multiplier;
- *base = tempRetval >= temp ? tempRetval : S_INT_MAX;
- }
- }
-}
-
void UnigramDictionary::getMissingSpaceWords(
const int inputLength, const int missingSpacePos, Correction *correction) {
correction->setCorrectionParams(-1 /* skipPos */, -1 /* excessivePos */,