Cleanup casts.

Change-Id: I3bf33ca407cc3bee9f5c4c6f929cdb1421b92c50
diff --git a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
index cf55580..2add7c9 100644
--- a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
+++ b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
@@ -230,8 +230,8 @@
     env->GetCharArrayRegion(before, 0, beforeLength, beforeChars);
     env->GetCharArrayRegion(after, 0, afterLength, afterChars);
     return Correction::RankingAlgorithm::calcNormalizedScore(
-            reinterpret_cast<unsigned short *>(beforeChars), beforeLength,
-            reinterpret_cast<unsigned short *>(afterChars), afterLength, score);
+            static_cast<unsigned short *>(beforeChars), beforeLength,
+            static_cast<unsigned short *>(afterChars), afterLength, score);
 }
 
 static jint latinime_BinaryDictionary_editDistance(JNIEnv *env, jobject object,
@@ -243,8 +243,8 @@
     env->GetCharArrayRegion(before, 0, beforeLength, beforeChars);
     env->GetCharArrayRegion(after, 0, afterLength, afterChars);
     return Correction::RankingAlgorithm::editDistance(
-            reinterpret_cast<unsigned short *>(beforeChars), beforeLength,
-            reinterpret_cast<unsigned short *>(afterChars), afterLength);
+            static_cast<unsigned short *>(beforeChars), beforeLength,
+            static_cast<unsigned short *>(afterChars), afterLength);
 }
 
 static void latinime_BinaryDictionary_close(JNIEnv *env, jobject object, jlong dict) {
diff --git a/native/jni/src/bigram_dictionary.cpp b/native/jni/src/bigram_dictionary.cpp
index df1ebc0..f1d5380 100644
--- a/native/jni/src/bigram_dictionary.cpp
+++ b/native/jni/src/bigram_dictionary.cpp
@@ -60,16 +60,15 @@
         AKLOGI("Bigram: InsertAt -> %d MAX_PREDICTIONS: %d", insertAt, MAX_PREDICTIONS);
     }
     if (insertAt < MAX_PREDICTIONS) {
-        memmove(reinterpret_cast<char *>(bigramFreq) + (insertAt + 1) * sizeof(bigramFreq[0]),
-                reinterpret_cast<char *>(bigramFreq) + insertAt * sizeof(bigramFreq[0]),
+        memmove(bigramFreq + (insertAt + 1),
+                bigramFreq + insertAt,
                 (MAX_PREDICTIONS - insertAt - 1) * sizeof(bigramFreq[0]));
         bigramFreq[insertAt] = frequency;
         outputTypes[insertAt] = Dictionary::KIND_PREDICTION;
-        memmove(reinterpret_cast<char *>(bigramChars)
-                + (insertAt + 1) * MAX_WORD_LENGTH * sizeof(short),
-                reinterpret_cast<char *>(bigramChars) + insertAt * MAX_WORD_LENGTH * sizeof(short),
-                (MAX_PREDICTIONS - insertAt - 1) * sizeof(short) * MAX_WORD_LENGTH);
-        unsigned short *dest = bigramChars + (insertAt    ) * MAX_WORD_LENGTH;
+        memmove(bigramChars + (insertAt + 1) * MAX_WORD_LENGTH,
+                bigramChars + insertAt * MAX_WORD_LENGTH,
+                (MAX_PREDICTIONS - insertAt - 1) * sizeof(bigramChars[0]) * MAX_WORD_LENGTH);
+        unsigned short *dest = bigramChars + insertAt * MAX_WORD_LENGTH;
         while (length--) {
             *dest++ = *word++;
         }
diff --git a/native/jni/src/char_utils.cpp b/native/jni/src/char_utils.cpp
index fc0a059..223291f 100644
--- a/native/jni/src/char_utils.cpp
+++ b/native/jni/src/char_utils.cpp
@@ -885,14 +885,13 @@
 };
 
 static int compare_pair_capital(const void *a, const void *b) {
-    return static_cast<int>(*reinterpret_cast<const unsigned short *>(a))
-            - static_cast<int>(
-                    (reinterpret_cast<const struct LatinCapitalSmallPair *>(b))->capital);
+    return static_cast<int>(*static_cast<const unsigned short *>(a))
+            - static_cast<int>((static_cast<const struct LatinCapitalSmallPair *>(b))->capital);
 }
 
 unsigned short latin_tolower(unsigned short c) {
     struct LatinCapitalSmallPair *p =
-            reinterpret_cast<struct LatinCapitalSmallPair *>(bsearch(&c, SORTED_CHAR_MAP,
+            static_cast<struct LatinCapitalSmallPair *>(bsearch(&c, SORTED_CHAR_MAP,
                     sizeof(SORTED_CHAR_MAP) / sizeof(SORTED_CHAR_MAP[0]),
                     sizeof(SORTED_CHAR_MAP[0]),
                     compare_pair_capital));
diff --git a/native/jni/src/debug.h b/native/jni/src/debug.h
index 2432b1f..4e21640 100644
--- a/native/jni/src/debug.h
+++ b/native/jni/src/debug.h
@@ -58,7 +58,7 @@
 }
 
 static inline void printDebug(const char *tag, int *codes, int codesSize, int MAX_PROXIMITY_CHARS) {
-    unsigned char *buf = reinterpret_cast<unsigned char *>(malloc((1 + codesSize) * sizeof(*buf)));
+    unsigned char *buf = static_cast<unsigned char *>(malloc((1 + codesSize) * sizeof(*buf)));
 
     buf[codesSize] = 0;
     while (--codesSize >= 0) {
diff --git a/native/jni/src/dictionary.cpp b/native/jni/src/dictionary.cpp
index 9e4bd15..158c3fb 100644
--- a/native/jni/src/dictionary.cpp
+++ b/native/jni/src/dictionary.cpp
@@ -32,8 +32,8 @@
 Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust,
         int typedLetterMultiplier, int fullWordMultiplier,
         int maxWordLength, int maxWords, int maxPredictions)
-    : mDict(reinterpret_cast<unsigned char *>(dict)),
-      mOffsetDict((reinterpret_cast<unsigned char *>(dict)) + BinaryFormat::getHeaderSize(mDict)),
+    : mDict(static_cast<unsigned char *>(dict)),
+      mOffsetDict((static_cast<unsigned char *>(dict)) + BinaryFormat::getHeaderSize(mDict)),
       mDictSize(dictSize), mMmapFd(mmapFd), mDictBufAdjust(dictBufAdjust) {
     if (DEBUG_DICT) {
         if (MAX_WORD_LENGTH_INTERNAL < maxWordLength) {
diff --git a/native/jni/src/words_priority_queue.h b/native/jni/src/words_priority_queue.h
index 2fad9bb..1e4e00a 100644
--- a/native/jni/src/words_priority_queue.h
+++ b/native/jni/src/words_priority_queue.h
@@ -140,13 +140,12 @@
                 continue;
             }
             const unsigned int wordLength = sw->mWordLength;
-            char *targetAddress = reinterpret_cast<char *>(outputChars)
-                    + i * MAX_WORD_LENGTH * sizeof(short);
+            unsigned short *targetAddress = outputChars + i * MAX_WORD_LENGTH;
             frequencies[i] = sw->mScore;
             outputTypes[i] = sw->mType;
-            memcpy(targetAddress, sw->mWord, (wordLength) * sizeof(short));
+            memcpy(targetAddress, sw->mWord, wordLength * sizeof(unsigned short));
             if (wordLength < MAX_WORD_LENGTH) {
-                reinterpret_cast<unsigned short *>(targetAddress)[wordLength] = 0;
+                targetAddress[wordLength] = 0;
             }
             sw->mUsed = false;
         }