gemini-code-assist[bot] commented on code in PR #18759:
URL: https://github.com/apache/tvm/pull/18759#discussion_r2795722465
##########
src/runtime/contrib/nvshmem/init.cc:
##########
@@ -82,28 +82,26 @@ void InitNVSHMEM(ffi::Shape uid_64, int num_workers, int
worker_id_start) {
}
void InitNVSHMEMWrapper(ffi::String args) {
- picojson::value v;
- std::string err = picojson::parse(v, args);
+ namespace json = tvm::ffi::json;
+ ffi::String err;
+ json::Value v = json::Parse(args, &err);
if (!err.empty()) {
LOG(FATAL) << "JSON parse error: " << err;
}
- if (!v.is<picojson::object>()) {
- LOG(FATAL) << "JSON is not an object";
- }
-
- picojson::object& obj = v.get<picojson::object>();
+ CHECK(v.as<json::Object>()) << "JSON is not an object";
+ json::Object obj = v.cast<json::Object>();
- picojson::array uid_array = obj["uid"].get<picojson::array>();
+ json::Array uid_array = obj[ffi::String("uid")].cast<json::Array>();
std::vector<int64_t> uid_vector;
Review Comment:

For a minor performance improvement and for consistency with other parts of
the codebase (e.g., `src/runtime/disco/loader.cc`), it's good practice to
reserve space for the `uid_vector` before populating it in the loop. This
avoids potential reallocations.
```c
std::vector<int64_t> uid_vector;
uid_vector.reserve(uid_array.size());
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]