A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
optimize perf - part 2
[simgrid.git]
/
src
/
bindings
/
java
/
jmsg_as.cpp
diff --git
a/src/bindings/java/jmsg_as.cpp
b/src/bindings/java/jmsg_as.cpp
index
8124ac4
..
d814976
100644
(file)
--- a/
src/bindings/java/jmsg_as.cpp
+++ b/
src/bindings/java/jmsg_as.cpp
@@
-13,7
+13,7
@@
#include "jxbt_utilities.h"
#include "jmsg.h"
#include "jxbt_utilities.h"
#include "jmsg.h"
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(j
msg
);
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(j
ava
);
SG_BEGIN_DECL()
SG_BEGIN_DECL()
@@
-129,27
+129,22
@@
JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getHosts(JNIEnv * env, jo
jobjectArray jtable;
jobject jhost;
jstring jname;
jobjectArray jtable;
jobject jhost;
jstring jname;
- msg_host_t host;
simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas);
simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas);
- xbt_dynar_t table = as->hosts();
- int count = xbt_dynar_length(table);
-
jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host");
jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host");
-
+ std::vector<sg_host_t>* table = as->hosts();
if (!cls)
return nullptr;
if (!cls)
return nullptr;
- jtable = env->NewObjectArray(static_cast<jsize>(
count
), cls, nullptr);
+ jtable = env->NewObjectArray(static_cast<jsize>(
table->size()
), cls, nullptr);
if (!jtable) {
jxbt_throw_jni(env, "Hosts table allocation failed");
return nullptr;
}
if (!jtable) {
jxbt_throw_jni(env, "Hosts table allocation failed");
return nullptr;
}
- for (int index = 0; index < count; index++) {
- host = xbt_dynar_get_as(table,index,msg_host_t);
-
+ int index = 0;
+ for (auto host : *table) {
jhost = static_cast<jobject>(host->extension(JAVA_HOST_LEVEL));
if (!jhost) {
jname = env->NewStringUTF(host->cname());
jhost = static_cast<jobject>(host->extension(JAVA_HOST_LEVEL));
if (!jhost) {
jname = env->NewStringUTF(host->cname());
@@
-160,8
+155,8
@@
JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getHosts(JNIEnv * env, jo
}
env->SetObjectArrayElement(jtable, index, jhost);
}
env->SetObjectArrayElement(jtable, index, jhost);
+ index++;
}
}
- xbt_dynar_free(&table);
return jtable;
}
return jtable;
}