From a5fac320ab8060e5f24540e0665a366d37516f75 Mon Sep 17 00:00:00 2001 From: Zach Nelson Date: Mon, 4 May 2026 08:45:15 -0500 Subject: [PATCH] refactor: Simplify sort in GfxRenderer::fillPolygon (#1817) ## Summary Small simplification to node sorting algorithm in GfxRenderer::fillPolygon. --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**NO**_ --- lib/GfxRenderer/GfxRenderer.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/GfxRenderer/GfxRenderer.cpp b/lib/GfxRenderer/GfxRenderer.cpp index 70e282c5..0fa56b77 100644 --- a/lib/GfxRenderer/GfxRenderer.cpp +++ b/lib/GfxRenderer/GfxRenderer.cpp @@ -5,6 +5,8 @@ #include #include +#include + #include "FontCacheManager.h" const uint8_t* GfxRenderer::getGlyphBitmap(const EpdFontData* fontData, const EpdGlyph* glyph) const { @@ -882,16 +884,8 @@ void GfxRenderer::fillPolygon(const int* xPoints, const int* yPoints, int numPoi j = i; } - // Sort nodes by X (simple bubble sort, numPoints is small) - for (int i = 0; i < nodes - 1; i++) { - for (int k = i + 1; k < nodes; k++) { - if (nodeX[i] > nodeX[k]) { - int temp = nodeX[i]; - nodeX[i] = nodeX[k]; - nodeX[k] = temp; - } - } - } + // Sort nodes by X + std::sort(nodeX, nodeX + nodes); // Fill between pairs of nodes for (int i = 0; i < nodes - 1; i += 2) {