summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorSuren Baghdasaryan <surenb@google.com>2021-02-11 16:14:37 -0800
committerSuren Baghdasaryan <surenb@google.com>2021-02-12 01:12:44 +0000
commit0c13c67158c5c1ca00b659a05f95de18a03fa57b (patch)
tree2e5c22921b992deecfdf02c0bee6975286853b03 /core
parentca115f206a9a7b182773937f7ebf043a18f2965d (diff)
Remove unnecessary calls to JNIEnv::GetArrayLength
Replace repeated calls to JNIEnv::GetArrayLength operating on the same array with a cached value obtained once and then reused. Bug: 165832481 Signed-off-by: Suren Baghdasaryan <surenb@google.com> Change-Id: Id85f887a9a4dc8eeacbb047beca7ced49853484e
Diffstat (limited to 'core')
-rw-r--r--core/jni/android_os_Debug.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/core/jni/android_os_Debug.cpp b/core/jni/android_os_Debug.cpp
index b5373f7347ae..c4caef2ecdb9 100644
--- a/core/jni/android_os_Debug.cpp
+++ b/core/jni/android_os_Debug.cpp
@@ -520,14 +520,15 @@ static jlong android_os_Debug_getPssPid(JNIEnv *env, jobject clazz, jint pid,
}
if (outUssSwapPssRss != NULL) {
- if (env->GetArrayLength(outUssSwapPssRss) >= 1) {
+ int outLen = env->GetArrayLength(outUssSwapPssRss);
+ if (outLen >= 1) {
jlong* outUssSwapPssRssArray = env->GetLongArrayElements(outUssSwapPssRss, 0);
if (outUssSwapPssRssArray != NULL) {
outUssSwapPssRssArray[0] = uss;
- if (env->GetArrayLength(outUssSwapPssRss) >= 2) {
+ if (outLen >= 2) {
outUssSwapPssRssArray[1] = swapPss;
}
- if (env->GetArrayLength(outUssSwapPssRss) >= 3) {
+ if (outLen >= 3) {
outUssSwapPssRssArray[2] = rss;
}
}
@@ -536,17 +537,18 @@ static jlong android_os_Debug_getPssPid(JNIEnv *env, jobject clazz, jint pid,
}
if (outMemtrack != NULL) {
- if (env->GetArrayLength(outMemtrack) >= 1) {
+ int outLen = env->GetArrayLength(outMemtrack);
+ if (outLen >= 1) {
jlong* outMemtrackArray = env->GetLongArrayElements(outMemtrack, 0);
if (outMemtrackArray != NULL) {
outMemtrackArray[0] = memtrack;
- if (env->GetArrayLength(outMemtrack) >= 2) {
+ if (outLen >= 2) {
outMemtrackArray[1] = graphics_mem.graphics;
}
- if (env->GetArrayLength(outMemtrack) >= 3) {
+ if (outLen >= 3) {
outMemtrackArray[2] = graphics_mem.gl;
}
- if (env->GetArrayLength(outMemtrack) >= 4) {
+ if (outLen >= 4) {
outMemtrackArray[3] = graphics_mem.other;
}
}