Remove the rejects tracking. There was some sort of bug in it and the added complexity didn't really bring about any huge perf gain
@@ -688,7 +688,6 @@ int H3_EXPORT(polyfill)(const GeoPolygon* geoPolygon, int res, H3Index* out) {
if (numHexagons < numVerts) numHexagons = numVerts;
H3Index* search = calloc(numHexagons, sizeof(H3Index));
H3Index* found = calloc(numHexagons, sizeof(H3Index));
- H3Index* rejects = calloc(numHexagons, sizeof(H3Index));
// Some metadata for tracking the state of the search and found memory
// blocks
@@ -725,7 +724,6 @@ int H3_EXPORT(polyfill)(const GeoPolygon* geoPolygon, int res, H3Index* out) {
if (loopCount > numHexagons) {
free(search);
free(found);
- free(rejects);
free(bboxes);
return -1;
}
@@ -780,7 +778,6 @@ int H3_EXPORT(polyfill)(const GeoPolygon* geoPolygon, int res, H3Index* out) {
if (loopCount > numHexagons) {
free(search);
free(found);
- free(rejects);
free(bboxes);
return -1;
}
@@ -791,23 +788,6 @@ int H3_EXPORT(polyfill)(const GeoPolygon* geoPolygon, int res, H3Index* out) {
if (out[loc] == hex) {
continue; // Skip this hex, already exists in the out hash
}
- loopCount = 0;
- int rloc = (int)(hex % numHexagons);
- while (rejects[rloc] != 0) {
- if (loopCount > numHexagons) {
- free(search);
- free(found);
- free(rejects);
- free(bboxes);
- return -1;
- }
- if (rejects[rloc] == hex) break; // Skip duplicates found
- rloc = (rloc + 1) % numHexagons;
- loopCount++;
- }
- if (rejects[rloc] == hex) {
- continue; // Skip this hex, already rejected
- }
// Check if the hexagon is in the polygon or not
GeoCoord hexCenter;
@@ -817,7 +797,6 @@ int H3_EXPORT(polyfill)(const GeoPolygon* geoPolygon, int res, H3Index* out) {
// If not, skip
if (!pointInsidePolygon(geoPolygon, bboxes, &hexCenter)) {
- rejects[rloc] = hex; // Mark this hex as rejected
continue;
}
@@ -830,6 +809,7 @@ int H3_EXPORT(polyfill)(const GeoPolygon* geoPolygon, int res, H3Index* out) {
// Wipe the current hex ring value back out
ring[j] = 0;
}
+ ring[0] = 0;
currentSearchNum++;
i++;
}
@@ -848,7 +828,6 @@ int H3_EXPORT(polyfill)(const GeoPolygon* geoPolygon, int res, H3Index* out) {
free(bboxes);
free(search);
free(found);
- free(rejects);
return 0;
}
