From 9c90894ff03f40b9ff0f3246b2285bc63816387b Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 19 May 2017 20:03:34 +0200 Subject: [PATCH] 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 --- src/ccstruct/pageres.cpp | 7 ------- src/ccstruct/pageres.h | 5 ++++- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/ccstruct/pageres.cpp b/src/ccstruct/pageres.cpp index cedae4ce34..ce61fc2ac2 100644 --- a/src/ccstruct/pageres.cpp +++ b/src/ccstruct/pageres.cpp @@ -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) { diff --git a/src/ccstruct/pageres.h b/src/ccstruct/pageres.h index f613a6ec27..df4e0f7720 100644 --- a/src/ccstruct/pageres.h +++ b/src/ccstruct/pageres.h @@ -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); }