From 21aa91fef7d2f6d1ff1e277df33a0674ba10ea0b Mon Sep 17 00:00:00 2001 From: TC6IDM <67088794+TC6IDM@users.noreply.github.com> Date: Sat, 1 Apr 2023 00:37:53 -0400 Subject: [PATCH] Guard Clause addition --- .../twitter/ann/faiss/swig/AlignedTableFloat32.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ann/src/main/java/com/twitter/ann/faiss/swig/AlignedTableFloat32.java b/ann/src/main/java/com/twitter/ann/faiss/swig/AlignedTableFloat32.java index 9758bd20d..3a14ec787 100644 --- a/ann/src/main/java/com/twitter/ann/faiss/swig/AlignedTableFloat32.java +++ b/ann/src/main/java/com/twitter/ann/faiss/swig/AlignedTableFloat32.java @@ -27,13 +27,12 @@ public class AlignedTableFloat32 { } public synchronized void delete() { - if (swigCPtr != 0) { - if (swigCMemOwn) { - swigCMemOwn = false; - swigfaissJNI.delete_AlignedTableFloat32(swigCPtr); - } - swigCPtr = 0; + if (swigCPtr == 0) return; + if (swigCMemOwn) { + swigCMemOwn = false; + swigfaissJNI.delete_AlignedTableFloat32(swigCPtr); } + swigCPtr = 0; } public void setTab(SWIGTYPE_p_faiss__AlignedTableTightAllocT_float_32_t value) {