From ed1e242866704d1f8654e44ed32c4b431d2d5795 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 25 May 2017 19:03:18 +0200 Subject: Improve jvppgen object array member instantiation Since all objects of the array have the same type, the object constructor is a loop invariant. Move the lookup out of the loop, making things faster. Change-Id: I631c72b59c6c63eccd49ede41c6dc0541c325db9 Signed-off-by: Robert Varga Signed-off-by: Robert Varga --- src/vpp-api/java/jvpp/gen/jvppgen/types_gen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/vpp-api/java/jvpp') diff --git a/src/vpp-api/java/jvpp/gen/jvppgen/types_gen.py b/src/vpp-api/java/jvpp/gen/jvppgen/types_gen.py index 22018e67009..858ea8baae7 100644 --- a/src/vpp-api/java/jvpp/gen/jvppgen/types_gen.py +++ b/src/vpp-api/java/jvpp/gen/jvppgen/types_gen.py @@ -91,9 +91,9 @@ object_array_dto_field_setter_template = Template(""" { jclass ${field_reference_name}Class = (*env)->FindClass(env, "${class_FQN}"); jobjectArray ${field_reference_name} = (*env)->NewObjectArray(env, ${field_length}, ${field_reference_name}Class, 0); + jmethodID ${field_reference_name}Constructor = (*env)->GetMethodID(env, ${field_reference_name}Class, "", "()V"); unsigned int _i; for (_i = 0; _i < ${field_length}; _i++) { - jmethodID ${field_reference_name}Constructor = (*env)->GetMethodID(env, ${field_reference_name}Class, "", "()V"); jobject ${field_reference_name}ArrayElement = (*env)->NewObject(env, ${field_reference_name}Class, ${field_reference_name}Constructor); ${type_initialization} (*env)->SetObjectArrayElement(env, ${field_reference_name}, _i, ${field_reference_name}ArrayElement); -- cgit 1.2.3-korg