Skip to content

Commit

Permalink
PAGE_RES_IT: Optimize compare operators by using inline code
Browse files Browse the repository at this point in the history
Avoiding a function call will make both == and != operator faster.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Mar 2, 2019
1 parent 7cc97c2 commit 9c90894
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
7 changes: 0 additions & 7 deletions src/ccstruct/pageres.cpp
Expand Up @@ -1191,13 +1191,6 @@ void WERD_RES::ClearRatings() {
}
}


bool PAGE_RES_IT::operator ==(const PAGE_RES_IT &other) const {
return word_res == other.word_res &&
row_res == other.row_res &&
block_res == other.block_res;
}

int PAGE_RES_IT::cmp(const PAGE_RES_IT &other) const {
ASSERT_HOST(page_res == other.page_res);
if (other.block_res == nullptr) {
Expand Down
5 changes: 4 additions & 1 deletion src/ccstruct/pageres.h
Expand Up @@ -685,7 +685,10 @@ class PAGE_RES_IT {

// Do two PAGE_RES_ITs point at the same word?
// This is much cheaper than cmp().
bool operator ==(const PAGE_RES_IT &other) const;
bool operator ==(const PAGE_RES_IT &other) const {
return word_res == other.word_res && row_res == other.row_res &&
block_res == other.block_res;
}

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

Expand Down

0 comments on commit 9c90894

Please sign in to comment.