summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max.kellermann@gmail.com>2021-03-28 13:07:37 +0200
committerMax Kellermann <max@musicpd.org>2021-04-06 13:26:29 +0200
commit296ec4d07c088f9f8370a0bf5f6a2858d4530400 (patch)
tree1af9e5bb14de22ede72c06297b35de4edfdfba6f
parent6e58fd15831180e9163f7fddceece92249f3dc9f (diff)
java/Ref: add nullptr check to destructor
May allow the compiler to optimize calls away.
-rw-r--r--src/java/Ref.hxx3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/java/Ref.hxx b/src/java/Ref.hxx
index 37c85a5e9..bd62b17d7 100644
--- a/src/java/Ref.hxx
+++ b/src/java/Ref.hxx
@@ -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;