From 4c01073ac1a6f6961c6835aae3fea0792b838a3b Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 12 Sep 2023 18:43:43 -0700 Subject: [PATCH] Improved variable scoping [skip ci] --- src/ivfkmeans.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ivfkmeans.c b/src/ivfkmeans.c index 7d02b3f..a87edcb 100644 --- a/src/ivfkmeans.c +++ b/src/ivfkmeans.c @@ -180,7 +180,6 @@ ElkanKmeans(Relation index, VectorArray samples, VectorArray centers) float *s; float *halfcdist; float *newcdist; - int closestCenter; /* Calculate allocation sizes */ Size samplesSize = VECTOR_ARRAY_SIZE(samples->maxlen, samples->dim); @@ -239,8 +238,7 @@ ElkanKmeans(Relation index, VectorArray samples, VectorArray centers) for (j = 0; j < numSamples; j++) { float minDistance = FLT_MAX; - - closestCenter = 0; + int closestCenter = 0; /* Find closest center */ for (k = 0; k < numCenters; k++) @@ -377,6 +375,8 @@ ElkanKmeans(Relation index, VectorArray samples, VectorArray centers) for (j = 0; j < numSamples; j++) { + int closestCenter; + vec = VectorArrayGet(samples, j); closestCenter = closestCenters[j];