Skip to content

Commit

Permalink
Make one-time comparator a lambda.
Browse files Browse the repository at this point in the history
  • Loading branch information
egorpugin committed Nov 22, 2024
1 parent b3e0c8e commit 66cf74f
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/ccstruct/polyblk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}
Expand All @@ -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) {
Expand Down

0 comments on commit 66cf74f

Please sign in to comment.