From 81d13bd40f03890bb5b6360259628cd473c2e467 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 3 Jan 2024 13:53:23 -0500 Subject: [PATCH] Improved code [skip ci] --- src/hnswbuild.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hnswbuild.c b/src/hnswbuild.c index b40c315..78438cb 100644 --- a/src/hnswbuild.c +++ b/src/hnswbuild.c @@ -375,13 +375,14 @@ InsertTupleInMemory(Relation index, Datum *values, ItemPointer heaptid, HnswBuil /* Add to graph memory context */ oldCtx = MemoryContextSwitchTo(buildstate->graphCtx); - if (dup != NULL) + if (dup == NULL) + buildstate->elements = lappend(buildstate->elements, element); + else { /* No need to free element since memory unlikely to be reallocated */ + /* Element is also used to estimate memory usage below */ HnswAddHeapTid(dup, heaptid); } - else - buildstate->elements = lappend(buildstate->elements, element); MemoryContextSwitchTo(oldCtx);