[sword-svn] r2589 - in trunk: bindings/java-jni/jni utilities
scribe at crosswire.org
scribe at crosswire.org
Sat Nov 6 10:53:46 MST 2010
Author: scribe
Date: 2010-11-06 10:53:46 -0700 (Sat, 06 Nov 2010)
New Revision: 2589
Modified:
trunk/bindings/java-jni/jni/swordstub.cpp
trunk/utilities/installmgr.cpp
Log:
Slightly optimized returning of search results in jni stub
Fixed progress reporting in cli installmgr
Modified: trunk/bindings/java-jni/jni/swordstub.cpp
===================================================================
--- trunk/bindings/java-jni/jni/swordstub.cpp 2010-11-06 16:24:45 UTC (rev 2588)
+++ trunk/bindings/java-jni/jni/swordstub.cpp 2010-11-06 17:53:46 UTC (rev 2589)
@@ -1161,20 +1161,24 @@
int i = 0;
jstring modName = env->NewStringUTF(assureValidUTF8(module->Name()));
+ jfieldID fieldIDModName = env->GetFieldID(clazzSearchHit, "modName", "Ljava/lang/String;");
+ jfieldID fieldIDKey = env->GetFieldID(clazzSearchHit, "key" , "Ljava/lang/String;");
+ jfieldID fieldIDScore = env->GetFieldID(clazzSearchHit, "score" , "J");
for (result = sword::TOP; !result.Error(); result++) {
jfieldID fieldID;
jobject searchHit = env->AllocObject(clazzSearchHit);
- fieldID = env->GetFieldID(clazzSearchHit, "modName", "Ljava/lang/String;"); env->SetObjectField(searchHit, fieldID, modName);
+ env->SetObjectField(searchHit, fieldIDModName, modName);
jstring key = env->NewStringUTF(assureValidUTF8((const char *)result));
- fieldID = env->GetFieldID(clazzSearchHit, "key", "Ljava/lang/String;"); env->SetObjectField(searchHit, fieldID, key);
+ env->SetObjectField(searchHit, fieldIDKey, key);
env->DeleteLocalRef(key);
- fieldID = env->GetFieldID(clazzSearchHit, "score", "J"); env->SetLongField(searchHit, fieldID, (long)result.getElement()->userData);
+ env->SetLongField(searchHit, fieldIDScore, (long)result.getElement()->userData);
env->SetObjectArrayElement(ret, i++, searchHit);
env->DeleteLocalRef(searchHit);
if (i >= MAX_RETURN_COUNT) break;
}
+ env->DeleteLocalRef(modName);
}
env->ReleaseStringUTFChars(scopeJS, scope);
Modified: trunk/utilities/installmgr.cpp
===================================================================
--- trunk/utilities/installmgr.cpp 2010-11-06 16:24:45 UTC (rev 2588)
+++ trunk/utilities/installmgr.cpp 2010-11-06 17:53:46 UTC (rev 2589)
@@ -82,7 +82,7 @@
class MyStatusReporter : public StatusReporter {
int last;
virtual void statusUpdate(double dltotal, double dlnow) {
- int p = 74 * (int)(dlnow / dltotal);
+ int p = (int)(74.0 * (dlnow / dltotal));
for (;last < p; ++last) {
if (!last) {
SWBuf output;
@@ -101,7 +101,7 @@
while (output.size() < 75) output += " ";
output += "]";
cout << "\n" << output.c_str() << "\n ";
- int p = 74 * (int)((double)completedBytes/totalBytes);
+ int p = (int)(74.0 * (double)completedBytes/totalBytes);
for (int i = 0; i < p; ++i) { cout << "="; }
cout << "\n\n" << message << "\n";
last = 0;
More information about the sword-cvs
mailing list