Skip to content

Commit 66cf74f

Browse files
committed
Make one-time comparator a lambda.
1 parent b3e0c8e commit 66cf74f

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/ccstruct/polyblk.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ namespace tesseract {
3434

3535
#define INTERSECTING INT16_MAX
3636

37-
int lessthan(const ICOORDELT *first, const ICOORDELT *second);
38-
3937
POLY_BLOCK::POLY_BLOCK(ICOORDELT_LIST *points, PolyBlockType t) {
4038
ICOORDELT_IT v = &vertices;
4139

@@ -357,7 +355,15 @@ ICOORDELT_LIST *PB_LINE_IT::get_line(TDimension y) {
357355
}
358356

359357
if (!r.empty()) {
360-
r.sort(lessthan);
358+
r.sort([](const ICOORDELT *p1, const ICOORDELT *p2) {
359+
if (p1->x() < p2->x()) {
360+
return (-1);
361+
} else if (p1->x() > p2->x()) {
362+
return (1);
363+
} else {
364+
return (0);
365+
}
366+
});
361367
for (r.mark_cycle_pt(); !r.cycled_list(); r.forward()) {
362368
x = r.data();
363369
}
@@ -371,16 +377,6 @@ ICOORDELT_LIST *PB_LINE_IT::get_line(TDimension y) {
371377
return result;
372378
}
373379

374-
int lessthan(const ICOORDELT *p1, const ICOORDELT *p2) {
375-
if (p1->x() < p2->x()) {
376-
return (-1);
377-
} else if (p1->x() > p2->x()) {
378-
return (1);
379-
} else {
380-
return (0);
381-
}
382-
}
383-
384380
#ifndef GRAPHICS_DISABLED
385381
/// Returns a color to draw the given type.
386382
ScrollView::Color POLY_BLOCK::ColorForPolyBlockType(PolyBlockType type) {

0 commit comments

Comments
 (0)