mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Cleanup casts.
Change-Id: I3bf33ca407cc3bee9f5c4c6f929cdb1421b92c50
This commit is contained in:
parent
54035065c0
commit
267030dd82
@ -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) {
|
||||
|
@ -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++;
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user