Update ConvertJObjectArrayToStdStringVector
Move the generated string instead of copy Add note that empty strings are dropped.
This commit is contained in:
Родитель
922e38d38b
Коммит
fa3a014fbf
|
@ -185,7 +185,7 @@ std::vector<std::string> ConvertJObjectArrayToStdStringVector(JNIEnv* env, const
|
|||
auto stringValue = JStringToStdString(env, jStringValue);
|
||||
if(!stringValue.empty())
|
||||
{
|
||||
stringVector.push_back(stringValue);
|
||||
stringVector.emplace_back(std::move(stringValue));
|
||||
}
|
||||
env->DeleteLocalRef(jStringValue);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,13 @@ namespace MAT_NS_BEGIN
|
|||
EventProperties GetEventProperties(JNIEnv*, const jstring&, const jstring&, const jint&, const jint&,
|
||||
const jdouble&, const jlong&, const jlong&, const jobjectArray&, const jobjectArray&);
|
||||
|
||||
/**
|
||||
* Convert a JObjectArray into a std::vector<std::string>
|
||||
* @param env
|
||||
* @param jArray
|
||||
* @return std::vector<std::string> containing the objects from JObjectArray.
|
||||
* @note If an object is an empty string, or we are unable to convert it to std::string, the value is not added to the vector.
|
||||
*/
|
||||
std::vector<std::string> ConvertJObjectArrayToStdStringVector(JNIEnv* env, const jobjectArray& jArray);
|
||||
|
||||
CommonDataContexts GenerateCommonDataContextObject(JNIEnv *env,
|
||||
|
|
Загрузка…
Ссылка в новой задаче