From 66cf74f2dd82790444ef321d3bf03fa303e9caef Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Sat, 23 Nov 2024 00:11:16 +0300 Subject: [PATCH] Make one-time comparator a lambda. --- src/ccstruct/polyblk.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/ccstruct/polyblk.cpp b/src/ccstruct/polyblk.cpp index bf2bc17193..993e10b683 100644 --- a/src/ccstruct/polyblk.cpp +++ b/src/ccstruct/polyblk.cpp @@ -34,8 +34,6 @@ namespace tesseract { #define INTERSECTING INT16_MAX -int lessthan(const ICOORDELT *first, const ICOORDELT *second); - POLY_BLOCK::POLY_BLOCK(ICOORDELT_LIST *points, PolyBlockType t) { ICOORDELT_IT v = &vertices; @@ -357,7 +355,15 @@ ICOORDELT_LIST *PB_LINE_IT::get_line(TDimension y) { } if (!r.empty()) { - r.sort(lessthan); + r.sort([](const ICOORDELT *p1, const ICOORDELT *p2) { + if (p1->x() < p2->x()) { + return (-1); + } else if (p1->x() > p2->x()) { + return (1); + } else { + return (0); + } + }); for (r.mark_cycle_pt(); !r.cycled_list(); r.forward()) { x = r.data(); } @@ -371,16 +377,6 @@ ICOORDELT_LIST *PB_LINE_IT::get_line(TDimension y) { return result; } -int lessthan(const ICOORDELT *p1, const ICOORDELT *p2) { - if (p1->x() < p2->x()) { - return (-1); - } else if (p1->x() > p2->x()) { - return (1); - } else { - return (0); - } -} - #ifndef GRAPHICS_DISABLED /// Returns a color to draw the given type. ScrollView::Color POLY_BLOCK::ColorForPolyBlockType(PolyBlockType type) {