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

Commit 1bc038c5 authored by satok's avatar satok
Browse files

Move correction state to stack memory

*Before
(0)  13.18 (0.01%)
(1)  93025.41 (62.06%)
(2)  10.75 (0.01%)
(3)  10.50 (0.01%)
(4)  117.50 (0.08%)
(5)  55678.98 (37.14%)
(6)  9.09 (0.01%)
(20) 883.84 (0.59%)
Total 149898.24 (sum of others 149749.25)

*After
(0)  17.41 (0.01%)
(1)  92673.41 (61.95%)
(2)  10.62 (0.01%)
(3)  10.37 (0.01%)
(4)  120.96 (0.08%)
(5)  55741.18 (37.26%)
(6)  11.01 (0.01%)
(20) 862.72 (0.58%)
Total 149595.52 (sum of others 149447.68)

Change-Id: Ia5a25a544fc388e4dab1e08d8f78d5117b249cf3
parent 78573f2e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ namespace latinime {

class AdditionalProximityChars {
 private:
    DISALLOW_IMPLICIT_CONSTRUCTORS(AdditionalProximityChars);
    static const std::string LOCALE_EN_US;
    static const int EN_US_ADDITIONAL_A_SIZE = 4;
    static const int32_t EN_US_ADDITIONAL_A[];
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ class BigramDictionary {
    bool isValidBigram(const int32_t *word1, int length1, const int32_t *word2, int length2);
    ~BigramDictionary();
 private:
    DISALLOW_IMPLICIT_CONSTRUCTORS(BigramDictionary);
    bool addWordBigram(unsigned short *word, int length, int frequency);
    int getBigramAddress(int *pos, bool advance);
    int getBigramFreq(int *pos);
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ namespace latinime {

class BinaryFormat {
 private:
    DISALLOW_IMPLICIT_CONSTRUCTORS(BinaryFormat);
    const static int32_t MINIMAL_ONE_BYTE_CHARACTER_VALUE = 0x20;
    const static int32_t CHARACTER_ARRAY_TERMINATOR = 0x1F;
    const static int MULTIPLE_BYTE_CHARACTER_ADDITIONAL_SIZE = 2;
+0 −5
Original line number Diff line number Diff line
@@ -106,11 +106,6 @@ inline bool Correction::isQuote(const unsigned short c) {
// Correction //
////////////////

Correction::Correction(const int typedLetterMultiplier, const int fullWordMultiplier)
        : TYPED_LETTER_MULTIPLIER(typedLetterMultiplier), FULL_WORD_MULTIPLIER(fullWordMultiplier) {
    initEditDistance(mEditDistanceTable);
}

void Correction::resetCorrection() {
    mTotalTraverseCount = 0;
}
+4 −5
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ class Correction {
        }
    }

    Correction(const int typedLetterMultiplier, const int fullWordMultiplier);
    Correction() {};
    void resetCorrection();
    void initCorrection(
            const ProximityInfo *pi, const int inputLength, const int maxWordLength);
@@ -175,8 +175,6 @@ class Correction {
     private:
        static const int CODE_SPACE = ' ';
        static const int MAX_INITIAL_SCORE = 255;
        static const int TYPED_LETTER_MULTIPLIER = 2;
        static const int FULL_WORD_MULTIPLIER = 2;
    };

    // proximity info state
@@ -195,6 +193,7 @@ class Correction {
    }

 private:
    DISALLOW_COPY_AND_ASSIGN(Correction);
    inline void incrementInputIndex();
    inline void incrementOutputIndex();
    inline void startToTraverseAllNodes();
@@ -206,8 +205,8 @@ class Correction {
    inline int getFinalProbabilityInternal(const int probability, unsigned short **word,
            int* wordLength, const int inputLength);

    const int TYPED_LETTER_MULTIPLIER;
    const int FULL_WORD_MULTIPLIER;
    static const int TYPED_LETTER_MULTIPLIER = 2;
    static const int FULL_WORD_MULTIPLIER = 2;
    const ProximityInfo *mProximityInfo;

    bool mUseFullEditDistance;
Loading