am 267030dd: Cleanup casts.

* commit '267030dd82a6165ca56899d2988b5dc51ebea104':
  Cleanup casts.
main
Ken Wakasa 2012-08-14 03:16:27 -07:00 committed by Android Git Automerger
commit 822139bdf4
6 changed files with 19 additions and 22 deletions

View File

@ -230,8 +230,8 @@ static jfloat latinime_BinaryDictionary_calcNormalizedScore(JNIEnv *env, jobject
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 @@ static jint latinime_BinaryDictionary_editDistance(JNIEnv *env, jobject object,
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) {

View File

@ -60,16 +60,15 @@ bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequ
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++;
}

View File

@ -885,14 +885,13 @@ static const struct LatinCapitalSmallPair SORTED_CHAR_MAP[] = {
};
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));

View File

@ -58,7 +58,7 @@ static inline void LOGI_S16_PLUS(unsigned short *string, const unsigned int leng
}
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) {

View File

@ -32,8 +32,8 @@ namespace latinime {
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) {

View File

@ -140,13 +140,12 @@ class WordsPriorityQueue {
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;
}