Skip to content

Commit 9c90894

Browse files
committed
PAGE_RES_IT: Optimize compare operators by using inline code
Avoiding a function call will make both == and != operator faster. Signed-off-by: Stefan Weil <[email protected]>
1 parent 7cc97c2 commit 9c90894

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/ccstruct/pageres.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -1191,13 +1191,6 @@ void WERD_RES::ClearRatings() {
11911191
}
11921192
}
11931193

1194-
1195-
bool PAGE_RES_IT::operator ==(const PAGE_RES_IT &other) const {
1196-
return word_res == other.word_res &&
1197-
row_res == other.row_res &&
1198-
block_res == other.block_res;
1199-
}
1200-
12011194
int PAGE_RES_IT::cmp(const PAGE_RES_IT &other) const {
12021195
ASSERT_HOST(page_res == other.page_res);
12031196
if (other.block_res == nullptr) {

src/ccstruct/pageres.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,10 @@ class PAGE_RES_IT {
685685

686686
// Do two PAGE_RES_ITs point at the same word?
687687
// This is much cheaper than cmp().
688-
bool operator ==(const PAGE_RES_IT &other) const;
688+
bool operator ==(const PAGE_RES_IT &other) const {
689+
return word_res == other.word_res && row_res == other.row_res &&
690+
block_res == other.block_res;
691+
}
689692

690693
bool operator !=(const PAGE_RES_IT &other) const {return !(*this == other); }
691694

0 commit comments

Comments
 (0)