From fecb8c06c93879b4767571b2399831383a170461 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Fri, 18 Aug 2023 20:49:00 -0700 Subject: [PATCH] Simplified code --- src/hnswscan.c | 4 ++-- src/hnswutils.c | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/hnswscan.c b/src/hnswscan.c index b3eded1..4a5c7f9 100644 --- a/src/hnswscan.c +++ b/src/hnswscan.c @@ -16,14 +16,14 @@ GetScanItems(IndexScanDesc scan, Datum q) Relation index = scan->indexRelation; FmgrInfo *procinfo = so->procinfo; Oid collation = so->collation; - List *ep = NIL; + List *ep; List *w; HnswElement entryPoint = HnswGetEntryPoint(index); if (entryPoint == NULL) return NIL; - ep = lappend(ep, HnswEntryCandidate(entryPoint, q, index, procinfo, collation, false)); + ep = list_make1(HnswEntryCandidate(entryPoint, q, index, procinfo, collation, false)); for (int lc = entryPoint->level; lc >= 1; lc--) { diff --git a/src/hnswutils.c b/src/hnswutils.c index 1beb4e9..55a55ee 100644 --- a/src/hnswutils.c +++ b/src/hnswutils.c @@ -926,21 +926,19 @@ RemoveElementsBeingDeleted(List *w) void HnswInsertElement(HnswElement element, HnswElement entryPoint, Relation index, FmgrInfo *procinfo, Oid collation, int m, int efConstruction, bool existing) { - List *ep = NIL; + List *ep; List *w; int level = element->level; int entryLevel; Datum q = PointerGetDatum(element->vec); HnswElement skipElement = existing ? element : NULL; - HnswCandidate *entryCandidate; /* No neighbors if no entry point */ if (entryPoint == NULL) return; /* Get entry point and level */ - entryCandidate = HnswEntryCandidate(entryPoint, q, index, procinfo, collation, true); - ep = lappend(ep, entryCandidate); + ep = list_make1(HnswEntryCandidate(entryPoint, q, index, procinfo, collation, true)); entryLevel = entryPoint->level; /* 1st phase: greedy search to insert level */