Skip to content

Commit

Permalink
Avoid conversion in return from getHolder
Browse files Browse the repository at this point in the history
Summary: Currently, we do a converting move from `local_ref<HybridDestructor::javaobject>` to `local_ref<HybridDestructor>`. Let's just return the right type directly, avoid the conversion, and save code size.

Reviewed By: mhorowitz

Differential Revision: D19354601

fbshipit-source-id: dd35170eb1a0a9dffa2765657b5331ea7ede1a33
  • Loading branch information
swolchok authored and facebook-github-bot committed Jan 13, 2020
1 parent 0be1856 commit ead6f66
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions first-party/fbjni/cxx/fbjni/detail/Hybrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ void setNativePointer(alias_ref<T> t, std::unique_ptr<detail::BaseHybridClass> n
// Inline rather than in cpp file so that consumers can call into
// their own copy directly rather than into the DSO containing fbjni,
// saving space for the symbol table.
inline JField<PrimitiveOrJniType<HybridDestructor::javaobject>> getDestructorField(const local_ref<JClass>& c) {
inline JField<HybridDestructor::javaobject> getDestructorField(const local_ref<JClass>& c) {
return c->template getField<HybridDestructor::javaobject>("mDestructor");
}

template<typename T>
local_ref<HybridDestructor> getHolder(const T* t) {
local_ref<HybridDestructor::javaobject> getHolder(const T* t) {
static auto holderField = getDestructorField(t->getClass());
return t->getFieldValue(holderField);
}
Expand Down

0 comments on commit ead6f66

Please sign in to comment.