summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnish Athalye <aathalye@google.com>2014-07-08 13:27:14 -0700
committerAnish Athalye <aathalye@google.com>2014-07-09 19:41:47 +0000
commit9b727000360c3cc103a36d4eb1f3b15e0ed8eae8 (patch)
treeb906d911683afd6595b880bed09b4d7790462ee7
parent21aa5ad5fbe3ffda506be018c48e9df5e67295eb (diff)
downloadframeworks_base-9b727000360c3cc103a36d4eb1f3b15e0ed8eae8.zip
frameworks_base-9b727000360c3cc103a36d4eb1f3b15e0ed8eae8.tar.gz
frameworks_base-9b727000360c3cc103a36d4eb1f3b15e0ed8eae8.tar.bz2
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
-rw-r--r--core/jni/android_text_StaticLayout.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/jni/android_text_StaticLayout.cpp b/core/jni/android_text_StaticLayout.cpp
index 696926c..9e20d18 100644
--- a/core/jni/android_text_StaticLayout.cpp
+++ b/core/jni/android_text_StaticLayout.cpp
@@ -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());