diff options
Diffstat (limited to 'native/jni/src/correction.cpp')
-rw-r--r-- | native/jni/src/correction.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/native/jni/src/correction.cpp b/native/jni/src/correction.cpp index 949158a0b..d7b67c98b 100644 --- a/native/jni/src/correction.cpp +++ b/native/jni/src/correction.cpp @@ -625,6 +625,29 @@ Correction::CorrectionType Correction::processCharAndCalcState(const int c, cons } } +/* static */ int Correction::powerIntCapped(const int base, const int n) { + if (n <= 0) return 1; + if (base == 2) { + return n < 31 ? 1 << n : S_INT_MAX; + } else { + int ret = base; + for (int i = 1; i < n; ++i) multiplyIntCapped(base, &ret); + return ret; + } +} + +/* static */ void Correction::multiplyRate(const int rate, int *freq) { + if (*freq != S_INT_MAX) { + if (*freq > 1000000) { + *freq /= 100; + multiplyIntCapped(rate, freq); + } else { + multiplyIntCapped(rate, freq); + *freq /= 100; + } + } +} + inline static int getQuoteCount(const int *word, const int length) { int quoteCount = 0; for (int i = 0; i < length; ++i) { |