From a34af79897ca59b558100112df4cadc0a498482d Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 8 Feb 2023 17:25:44 +0000 Subject: [PATCH] ECC-1526: Performance: Unnecessary decoding during nearest neighbour computation --- src/grib_nearest_class_latlon_reduced.cc | 5 ++--- src/grib_nearest_class_reduced.cc | 5 ++--- src/grib_nearest_class_regular.cc | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/grib_nearest_class_latlon_reduced.cc b/src/grib_nearest_class_latlon_reduced.cc index fc682ed05..9262723c6 100644 --- a/src/grib_nearest_class_latlon_reduced.cc +++ b/src/grib_nearest_class_latlon_reduced.cc @@ -182,7 +182,6 @@ static int find_global(grib_nearest* nearest, grib_handle* h, * This is for performance: if the grid has not changed, we only do this once * and reuse for other messages */ if (!nearest->h || (flags & GRIB_NEAREST_SAME_GRID) == 0) { - double dummy = 0; double olat = 1.e10; long n = 0; @@ -211,12 +210,12 @@ static int find_global(grib_nearest* nearest, grib_handle* h, if (!self->lons) return GRIB_OUT_OF_MEMORY; - iter = grib_iterator_new(h, 0, &ret); + iter = grib_iterator_new(h, GRIB_GEOITERATOR_NO_VALUES, &ret); if (ret) { grib_context_log(h->context, GRIB_LOG_ERROR, "unable to create iterator"); return ret; } - while (grib_iterator_next(iter, &lat, &lon, &dummy)) { + while (grib_iterator_next(iter, &lat, &lon, NULL)) { if (olat != lat) { self->lats[ilat++] = lat; olat = lat; diff --git a/src/grib_nearest_class_reduced.cc b/src/grib_nearest_class_reduced.cc index 4e034e9b8..6a0777be7 100644 --- a/src/grib_nearest_class_reduced.cc +++ b/src/grib_nearest_class_reduced.cc @@ -215,7 +215,6 @@ static int find_global(grib_nearest* nearest, grib_handle* h, * This is for performance: if the grid has not changed, we only do this once * and reuse for other messages */ if (!nearest->h || (flags & GRIB_NEAREST_SAME_GRID) == 0) { - double dummy = 0; double olat = 1.e10; long n = 0; @@ -244,12 +243,12 @@ static int find_global(grib_nearest* nearest, grib_handle* h, if (!self->lons) return GRIB_OUT_OF_MEMORY; - iter = grib_iterator_new(h, 0, &ret); + iter = grib_iterator_new(h, GRIB_GEOITERATOR_NO_VALUES, &ret); if (ret != GRIB_SUCCESS) { grib_context_log(h->context, GRIB_LOG_ERROR, "grib_nearest_reduced: Unable to create lat/lon iterator"); return ret; } - while (grib_iterator_next(iter, &lat, &lon, &dummy)) { + while (grib_iterator_next(iter, &lat, &lon, NULL)) { if (olat != lat) { self->lats[ilat++] = lat; olat = lat; diff --git a/src/grib_nearest_class_regular.cc b/src/grib_nearest_class_regular.cc index 132da2f5f..25cf38347 100644 --- a/src/grib_nearest_class_regular.cc +++ b/src/grib_nearest_class_regular.cc @@ -253,7 +253,6 @@ static int find(grib_nearest* nearest, grib_handle* h, * This is for performance: if the grid has not changed, we only do this once * and reuse for other messages */ if (!nearest->h || (flags & GRIB_NEAREST_SAME_GRID) == 0) { - double dummy = 0; double olat = 1.e10, olon = 1.e10; int ilat = 0, ilon = 0; long n = 0; @@ -316,12 +315,12 @@ static int find(grib_nearest* nearest, grib_handle* h, if (!self->lons) return GRIB_OUT_OF_MEMORY; - iter = grib_iterator_new(h, 0, &ret); + iter = grib_iterator_new(h, GRIB_GEOITERATOR_NO_VALUES, &ret); if (ret != GRIB_SUCCESS) { grib_context_log(h->context, GRIB_LOG_ERROR, "grib_nearest_regular: Unable to create lat/lon iterator"); return ret; } - while (grib_iterator_next(iter, &lat, &lon, &dummy)) { + while (grib_iterator_next(iter, &lat, &lon, NULL)) { if (ilat < self->lats_count && olat != lat) { /* Assert(ilat < self->lats_count); */ self->lats[ilat++] = lat;