java/Ref: add nullptr check to destructor

May allow the compiler to optimize calls away.
This commit is contained in:
Max Kellermann 2021-03-28 13:07:37 +02:00 committed by Max Kellermann
parent 6e58fd1583
commit 296ec4d07c

View File

@ -62,7 +62,8 @@ namespace Java {
value(std::exchange(src.value, nullptr)) {}
~LocalRef() noexcept {
env->DeleteLocalRef(value);
if (value != nullptr)
env->DeleteLocalRef(value);
}
LocalRef(const LocalRef &other) = delete;