Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03eef94a authored by Jing Mike's avatar Jing Mike Committed by Mike Jing
Browse files

Remove unused variables



Since some variables with module LatinIME are defined but not used,
when compiled with build combination "sdk_pc_x86_64-userdebug" and
build command "mmm packages/inputmethods/LatinIME", the following
code lines will be reported that "variable 'XXX' set but not used".
(should be similar for all the other build combinations)

Repeated 10 times for each:
terminal_position_lookup_table.cpp:74:9 removedEntryCount
terminal_position_lookup_table.cpp:85:9 removedEntryCount
proximity_info_state_utils.cpp:493:9 tempTime
trie_map.cpp:56:9 unusedRegionSize
suggestion_results.cpp:100:9 index

Repeated 80+ times:
proximity_info_utils.h:75:25 proximityChar

With this patch we are removing some of the unused variables and
putting the C++ 17 attribute [[maybe_unused]] to the others which
are used for logging. Then all the related build warnings have been
eliminated.

Test: mmm packages/inputmethods/LatinIME, presubmit check.

Change-Id: Ia66766322d6ae8a010b1cb55cc22993fbc6d012c
Signed-off-by: default avatarJing Mike <jingyangliu@eswincomputing.com>
parent ce22ebc5
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -82,14 +82,12 @@ bool TerminalPositionLookupTable::flushToFile(const char *const dictPath) const
}

bool TerminalPositionLookupTable::runGCTerminalIds(TerminalIdMap *const terminalIdMap) {
    int removedEntryCount = 0;
    int nextNewTerminalId = 0;
    for (int i = 0; i < mSize; ++i) {
        const int terminalPos = getBuffer()->readUint(
                Ver4DictConstants::TERMINAL_ADDRESS_TABLE_ADDRESS_SIZE, getEntryPos(i));
        if (terminalPos == Ver4DictConstants::NOT_A_TERMINAL_ADDRESS) {
            // This entry is a garbage.
            removedEntryCount++;
        } else {
            // Give a new terminal id to the entry.
            if (!getWritableBuffer()->writeUint(terminalPos,
+0 −2
Original line number Diff line number Diff line
@@ -71,14 +71,12 @@ bool TerminalPositionLookupTable::flushToFile(FILE *const file) const {
}

bool TerminalPositionLookupTable::runGCTerminalIds(TerminalIdMap *const terminalIdMap) {
    int removedEntryCount = 0;
    int nextNewTerminalId = 0;
    for (int i = 0; i < mSize; ++i) {
        const int terminalPos = getBuffer()->readUint(
                Ver4DictConstants::TERMINAL_ADDRESS_TABLE_ADDRESS_SIZE, getEntryPos(i));
        if (terminalPos == Ver4DictConstants::NOT_A_TERMINAL_ADDRESS) {
            // This entry is a garbage.
            removedEntryCount++;
        } else {
            // Give a new terminal id to the entry.
            if (!getWritableBuffer()->writeUint(terminalPos,
+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ void TrieMap::dump(const int from, const int to) const {
    for (int i = from; i < to; ++i) {
        AKLOGI("Entry[%d]: %x, %x", i, readField0(i), readField1(i));
    }
    int unusedRegionSize = 0;
    [[maybe_unused]] int unusedRegionSize = 0;
    for (int i = 1; i <= MAX_NUM_OF_ENTRIES_IN_ONE_LEVEL; ++i) {
        int index = readEmptyTableLink(i);
        while (index != ROOT_BITMAP_ENTRY_INDEX) {
+0 −4
Original line number Diff line number Diff line
@@ -490,12 +490,10 @@ namespace latinime {
    const int x0 = (*sampledInputXs)[id];
    const int y0 = (*sampledInputYs)[id];
    const int actualInputIndex = (*sampledInputIndices)[id];
    int tempTime = 0;
    int tempBeelineDistance = 0;
    int start = actualInputIndex;
    // lookup forward
    while (start > 0 && tempBeelineDistance < lookupRadius) {
        tempTime += times[start] - times[start - 1];
        --start;
        tempBeelineDistance = GeometryUtils::getDistanceInt(x0, y0, xCoordinates[start],
                yCoordinates[start]);
@@ -504,12 +502,10 @@ namespace latinime {
    if (start > 0 && start < actualInputIndex) {
        ++start;
    }
    tempTime= 0;
    tempBeelineDistance = 0;
    int end = actualInputIndex;
    // lookup backward
    while (end < (inputSize - 1) && tempBeelineDistance < lookupRadius) {
        tempTime += times[end + 1] - times[end];
        ++end;
        tempBeelineDistance = GeometryUtils::getDistanceInt(x0, y0, xCoordinates[end],
                yCoordinates[end]);
+1 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ class ProximityInfoUtils {
            for (int i = 0; i < inputSize; ++i) {
                AKLOGI("---");
                for (int j = 0; j < MAX_PROXIMITY_CHARS_SIZE; ++j) {
                    int proximityChar =
                    [[maybe_unused]] int proximityChar =
                            inputProximities[i * MAX_PROXIMITY_CHARS_SIZE + j];
                    proximityChar += 0;
                    AKLOGI("--- (%d)%c", i, proximityChar);
Loading