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

Commit 9b727000 authored by Anish Athalye's avatar Anish Athalye
Browse files

Fix extraneous allocation and copying

With breaks being allocated the way it was, there were 16 ints with
value 0 being stored in the beginning of the vector. Because of the way
the rest of the code is structured, this did not result in incorrect
operation, but it still wasted time and memory.

Change-Id: Ic0df3e5484417da51f2465ec2d72222fefffc18a
parent 21aa5ad5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ static jintArray nLineBreakOpportunities(JNIEnv* env, jclass, jstring javaLocale
                                        jcharArray inputText, jint length,
                                        jintArray recycle) {
    jintArray ret;
    std::vector<jint> breaks(16);
    std::vector<jint> breaks;

    ScopedIcuLocale icuLocale(env, javaLocaleName);
    if (icuLocale.valid()) {
@@ -84,7 +84,7 @@ static jintArray nLineBreakOpportunities(JNIEnv* env, jclass, jstring javaLocale

    breaks.push_back(-1); // sentinel terminal value

    if (recycle != NULL && env->GetArrayLength(recycle) >= breaks.size()) {
    if (recycle != NULL && static_cast<size_t>(env->GetArrayLength(recycle)) >= breaks.size()) {
        ret = recycle;
    } else {
        ret = env->NewIntArray(breaks.size());