mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
[perf][1/5] Replace IValue::toString()->string() with IValue::toStringRef() (#85437)
Summary: `IValue::toString()` creates a `new c10::intrusive_ptr` (like `std::shared_ptr`) and `->string()` immediately accesses it, creating an atomic reference increment/decrement. We can skip both of these operations by calling `IValue::toStringRef()`. Test Plan: CI Reviewed By: jaybean-dev Differential Revision: D39605242 Pull Request resolved: https://github.com/pytorch/pytorch/pull/85437 Approved by: https://github.com/jfix71
This commit is contained in:
committed by
PyTorch MergeBot
parent
ea81138bd6
commit
a38e43e936
@ -303,7 +303,7 @@ facebook::jni::local_ref<JIValue> JIValue::newJIValueFromStringDict(
|
||||
facebook::jni::alias_ref<JIValue::javaobject>>::create();
|
||||
for (auto& pair : dict) {
|
||||
jmap->put(
|
||||
facebook::jni::make_jstring(pair.key().toString()->string()),
|
||||
facebook::jni::make_jstring(pair.key().toStringRef()),
|
||||
JIValue::newJIValueFromAtIValue(pair.value()));
|
||||
}
|
||||
return jMethodDictStringKey(JIValue::javaClassStatic(), jmap);
|
||||
|
Reference in New Issue
Block a user