Commit 2fbcca78 for tesseract

commit 2fbcca783be6376abdf873acc466cccdf7427629
Author: Stefan Weil <sw@weilnetz.de>
Date:   Thu Apr 8 10:30:59 2021 +0200

    Make more functions in class REJ inline

    Signed-off-by: Stefan Weil <sw@weilnetz.de>

diff --git a/src/ccstruct/rejctmap.cpp b/src/ccstruct/rejctmap.cpp
index a69a374c..7335f812 100644
--- a/src/ccstruct/rejctmap.cpp
+++ b/src/ccstruct/rejctmap.cpp
@@ -24,165 +24,6 @@

 namespace tesseract {

-bool REJ::perm_rejected() const { // Is char perm reject?
-  return (flag(R_TESS_FAILURE) || flag(R_SMALL_XHT) || flag(R_EDGE_CHAR) || flag(R_1IL_CONFLICT) ||
-          flag(R_POSTNN_1IL) || flag(R_REJ_CBLOB) || flag(R_BAD_REPETITION) || flag(R_MM_REJECT));
-}
-
-bool REJ::rej_before_nn_accept() const {
-  return flag(R_POOR_MATCH) || flag(R_NOT_TESS_ACCEPTED) || flag(R_CONTAINS_BLANKS) ||
-         flag(R_BAD_PERMUTER);
-}
-
-bool REJ::rej_between_nn_and_mm() const {
-  return flag(R_HYPHEN) || flag(R_DUBIOUS) || flag(R_NO_ALPHANUMS) || flag(R_MOSTLY_REJ) ||
-         flag(R_XHT_FIXUP);
-}
-
-bool REJ::rej_between_mm_and_quality_accept() const {
-  return flag(R_BAD_QUALITY);
-}
-
-bool REJ::rej_between_quality_and_minimal_rej_accept() const {
-  return flag(R_DOC_REJ) || flag(R_BLOCK_REJ) || flag(R_ROW_REJ) || flag(R_UNLV_REJ);
-}
-
-bool REJ::rej_before_mm_accept() const {
-  return rej_between_nn_and_mm() ||
-         (rej_before_nn_accept() && !flag(R_NN_ACCEPT) && !flag(R_HYPHEN_ACCEPT));
-}
-
-bool REJ::rej_before_quality_accept() const {
-  return rej_between_mm_and_quality_accept() || (!flag(R_MM_ACCEPT) && rej_before_mm_accept());
-}
-
-bool REJ::rejected() const { // Is char rejected?
-  if (flag(R_MINIMAL_REJ_ACCEPT)) {
-    return false;
-  } else {
-    return (perm_rejected() || rej_between_quality_and_minimal_rej_accept() ||
-            (!flag(R_QUALITY_ACCEPT) && rej_before_quality_accept()));
-  }
-}
-
-bool REJ::accept_if_good_quality() const { // potential rej?
-  return (rejected() && !perm_rejected() && flag(R_BAD_PERMUTER) && !flag(R_POOR_MATCH) &&
-          !flag(R_NOT_TESS_ACCEPTED) && !flag(R_CONTAINS_BLANKS) &&
-          (!rej_between_nn_and_mm() && !rej_between_mm_and_quality_accept() &&
-           !rej_between_quality_and_minimal_rej_accept()));
-}
-
-void REJ::setrej_tess_failure() { // Tess generated blank
-  set_flag(R_TESS_FAILURE);
-}
-
-void REJ::setrej_small_xht() { // Small xht char/wd
-  set_flag(R_SMALL_XHT);
-}
-
-void REJ::setrej_edge_char() { // Close to image edge
-  set_flag(R_EDGE_CHAR);
-}
-
-void REJ::setrej_1Il_conflict() { // Initial reject map
-  set_flag(R_1IL_CONFLICT);
-}
-
-void REJ::setrej_postNN_1Il() { // 1Il after NN
-  set_flag(R_POSTNN_1IL);
-}
-
-void REJ::setrej_rej_cblob() { // Insert duff blob
-  set_flag(R_REJ_CBLOB);
-}
-
-void REJ::setrej_mm_reject() { // Matrix matcher
-  set_flag(R_MM_REJECT);
-}
-
-void REJ::setrej_bad_repetition() { // Odd repeated char
-  set_flag(R_BAD_REPETITION);
-}
-
-void REJ::setrej_poor_match() { // Failed Rays heuristic
-  set_flag(R_POOR_MATCH);
-}
-
-void REJ::setrej_not_tess_accepted() {
-  // TEMP reject_word
-  set_flag(R_NOT_TESS_ACCEPTED);
-}
-
-void REJ::setrej_contains_blanks() {
-  // TEMP reject_word
-  set_flag(R_CONTAINS_BLANKS);
-}
-
-void REJ::setrej_bad_permuter() { // POTENTIAL reject_word
-  set_flag(R_BAD_PERMUTER);
-}
-
-void REJ::setrej_hyphen() { // PostNN dubious hyphen or .
-  set_flag(R_HYPHEN);
-}
-
-void REJ::setrej_dubious() { // PostNN dubious limit
-  set_flag(R_DUBIOUS);
-}
-
-void REJ::setrej_no_alphanums() { // TEMP reject_word
-  set_flag(R_NO_ALPHANUMS);
-}
-
-void REJ::setrej_mostly_rej() { // TEMP reject_word
-  set_flag(R_MOSTLY_REJ);
-}
-
-void REJ::setrej_xht_fixup() { // xht fixup
-  set_flag(R_XHT_FIXUP);
-}
-
-void REJ::setrej_bad_quality() { // TEMP reject_word
-  set_flag(R_BAD_QUALITY);
-}
-
-void REJ::setrej_doc_rej() { // TEMP reject_word
-  set_flag(R_DOC_REJ);
-}
-
-void REJ::setrej_block_rej() { // TEMP reject_word
-  set_flag(R_BLOCK_REJ);
-}
-
-void REJ::setrej_row_rej() { // TEMP reject_word
-  set_flag(R_ROW_REJ);
-}
-
-void REJ::setrej_unlv_rej() { // TEMP reject_word
-  set_flag(R_UNLV_REJ);
-}
-
-void REJ::setrej_hyphen_accept() { // NN Flipped a char
-  set_flag(R_HYPHEN_ACCEPT);
-}
-
-void REJ::setrej_nn_accept() { // NN Flipped a char
-  set_flag(R_NN_ACCEPT);
-}
-
-void REJ::setrej_mm_accept() { // Matrix matcher
-  set_flag(R_MM_ACCEPT);
-}
-
-void REJ::setrej_quality_accept() { // Quality flip a char
-  set_flag(R_QUALITY_ACCEPT);
-}
-
-void REJ::setrej_minimal_rej_accept() {
-  // Accept all except blank
-  set_flag(R_MINIMAL_REJ_ACCEPT);
-}
-
 void REJ::full_print(FILE *fp) const {
   fprintf(fp, "R_TESS_FAILURE: %s\n", flag(R_TESS_FAILURE) ? "T" : "F");
   fprintf(fp, "R_SMALL_XHT: %s\n", flag(R_SMALL_XHT) ? "T" : "F");
@@ -193,7 +34,8 @@ void REJ::full_print(FILE *fp) const {
   fprintf(fp, "R_MM_REJECT: %s\n", flag(R_MM_REJECT) ? "T" : "F");
   fprintf(fp, "R_BAD_REPETITION: %s\n", flag(R_BAD_REPETITION) ? "T" : "F");
   fprintf(fp, "R_POOR_MATCH: %s\n", flag(R_POOR_MATCH) ? "T" : "F");
-  fprintf(fp, "R_NOT_TESS_ACCEPTED: %s\n", flag(R_NOT_TESS_ACCEPTED) ? "T" : "F");
+  fprintf(fp, "R_NOT_TESS_ACCEPTED: %s\n",
+          flag(R_NOT_TESS_ACCEPTED) ? "T" : "F");
   fprintf(fp, "R_CONTAINS_BLANKS: %s\n", flag(R_CONTAINS_BLANKS) ? "T" : "F");
   fprintf(fp, "R_BAD_PERMUTER: %s\n", flag(R_BAD_PERMUTER) ? "T" : "F");
   fprintf(fp, "R_HYPHEN: %s\n", flag(R_HYPHEN) ? "T" : "F");
@@ -210,7 +52,8 @@ void REJ::full_print(FILE *fp) const {
   fprintf(fp, "R_NN_ACCEPT: %s\n", flag(R_NN_ACCEPT) ? "T" : "F");
   fprintf(fp, "R_MM_ACCEPT: %s\n", flag(R_MM_ACCEPT) ? "T" : "F");
   fprintf(fp, "R_QUALITY_ACCEPT: %s\n", flag(R_QUALITY_ACCEPT) ? "T" : "F");
-  fprintf(fp, "R_MINIMAL_REJ_ACCEPT: %s\n", flag(R_MINIMAL_REJ_ACCEPT) ? "T" : "F");
+  fprintf(fp, "R_MINIMAL_REJ_ACCEPT: %s\n",
+          flag(R_MINIMAL_REJ_ACCEPT) ? "T" : "F");
 }

 REJMAP &REJMAP::operator=(const REJMAP &source) {
diff --git a/src/ccstruct/rejctmap.h b/src/ccstruct/rejctmap.h
index 56340ab7..8f562764 100644
--- a/src/ccstruct/rejctmap.h
+++ b/src/ccstruct/rejctmap.h
@@ -108,13 +108,6 @@ class REJ {
     }
   }

-  bool rej_before_nn_accept() const;
-  bool rej_between_nn_and_mm() const;
-  bool rej_between_mm_and_quality_accept() const;
-  bool rej_between_quality_and_minimal_rej_accept() const;
-  bool rej_before_mm_accept() const;
-  bool rej_before_quality_accept() const;
-
 public:
   REJ() = default;

@@ -147,54 +140,180 @@ public:
     }
   }

-  bool perm_rejected() const; // Is char perm reject?
+  bool perm_rejected() const { // Is char perm reject?
+    return (flag(R_TESS_FAILURE) || flag(R_SMALL_XHT) || flag(R_EDGE_CHAR) ||
+            flag(R_1IL_CONFLICT) || flag(R_POSTNN_1IL) || flag(R_REJ_CBLOB) ||
+            flag(R_BAD_REPETITION) || flag(R_MM_REJECT));
+  }
+
+private:
+  bool rej_before_nn_accept() const {
+    return flag(R_POOR_MATCH) || flag(R_NOT_TESS_ACCEPTED) ||
+           flag(R_CONTAINS_BLANKS) || flag(R_BAD_PERMUTER);
+  }
+
+  bool rej_between_nn_and_mm() const {
+    return flag(R_HYPHEN) || flag(R_DUBIOUS) || flag(R_NO_ALPHANUMS) ||
+           flag(R_MOSTLY_REJ) || flag(R_XHT_FIXUP);
+  }
+
+  bool rej_between_mm_and_quality_accept() const {
+    return flag(R_BAD_QUALITY);
+  }
+
+  bool rej_between_quality_and_minimal_rej_accept() const {
+    return flag(R_DOC_REJ) || flag(R_BLOCK_REJ) || flag(R_ROW_REJ) ||
+           flag(R_UNLV_REJ);
+  }
+
+  bool rej_before_mm_accept() const {
+    return rej_between_nn_and_mm() ||
+           (rej_before_nn_accept() && !flag(R_NN_ACCEPT) &&
+            !flag(R_HYPHEN_ACCEPT));
+  }
+
+  bool rej_before_quality_accept() const {
+    return rej_between_mm_and_quality_accept() ||
+           (!flag(R_MM_ACCEPT) && rej_before_mm_accept());
+  }
+
+public:
+  bool rejected() const { // Is char rejected?
+    if (flag(R_MINIMAL_REJ_ACCEPT)) {
+      return false;
+    } else {
+      return (perm_rejected() || rej_between_quality_and_minimal_rej_accept() ||
+              (!flag(R_QUALITY_ACCEPT) && rej_before_quality_accept()));
+    }
+  }
+
+  bool accept_if_good_quality() const { // potential rej?
+    return (rejected() && !perm_rejected() && flag(R_BAD_PERMUTER) &&
+            !flag(R_POOR_MATCH) && !flag(R_NOT_TESS_ACCEPTED) &&
+            !flag(R_CONTAINS_BLANKS) &&
+            (!rej_between_nn_and_mm() && !rej_between_mm_and_quality_accept() &&
+             !rej_between_quality_and_minimal_rej_accept()));
+  }
+
+  void setrej_tess_failure() { // Tess generated blank
+    set_flag(R_TESS_FAILURE);
+  }
+
+  void setrej_small_xht() { // Small xht char/wd
+    set_flag(R_SMALL_XHT);
+  }
+
+  void setrej_edge_char() { // Close to image edge
+    set_flag(R_EDGE_CHAR);
+  }
+
+  void setrej_1Il_conflict() { // Initial reject map
+    set_flag(R_1IL_CONFLICT);
+  }
+
+  void setrej_postNN_1Il() { // 1Il after NN
+    set_flag(R_POSTNN_1IL);
+  }
+
+  void setrej_rej_cblob() { // Insert duff blob
+    set_flag(R_REJ_CBLOB);
+  }
+
+  void setrej_mm_reject() { // Matrix matcher
+    set_flag(R_MM_REJECT);
+  }
+
+  void setrej_bad_repetition() { // Odd repeated char
+    set_flag(R_BAD_REPETITION);
+  }
+
+  void setrej_poor_match() { // Failed Rays heuristic
+    set_flag(R_POOR_MATCH);
+  }
+
+  void setrej_not_tess_accepted() {
+    // TEMP reject_word
+    set_flag(R_NOT_TESS_ACCEPTED);
+  }
+
+  void setrej_contains_blanks() {
+    // TEMP reject_word
+    set_flag(R_CONTAINS_BLANKS);
+  }
+
+  void setrej_bad_permuter() { // POTENTIAL reject_word
+    set_flag(R_BAD_PERMUTER);
+  }
+
+  void setrej_hyphen() { // PostNN dubious hyphen or .
+    set_flag(R_HYPHEN);
+  }
+
+  void setrej_dubious() { // PostNN dubious limit
+    set_flag(R_DUBIOUS);
+  }
+
+  void setrej_no_alphanums() { // TEMP reject_word
+    set_flag(R_NO_ALPHANUMS);
+  }
+
+  void setrej_mostly_rej() { // TEMP reject_word
+    set_flag(R_MOSTLY_REJ);
+  }
+
+  void setrej_xht_fixup() { // xht fixup
+    set_flag(R_XHT_FIXUP);
+  }
+
+  void setrej_bad_quality() { // TEMP reject_word
+    set_flag(R_BAD_QUALITY);
+  }

-  bool rejected() const; // Is char rejected?
+  void setrej_doc_rej() { // TEMP reject_word
+    set_flag(R_DOC_REJ);
+  }
+
+  void setrej_block_rej() { // TEMP reject_word
+    set_flag(R_BLOCK_REJ);
+  }
+
+  void setrej_row_rej() { // TEMP reject_word
+    set_flag(R_ROW_REJ);
+  }
+
+  void setrej_unlv_rej() { // TEMP reject_word
+    set_flag(R_UNLV_REJ);
+  }
+
+  void setrej_hyphen_accept() { // NN Flipped a char
+    set_flag(R_HYPHEN_ACCEPT);
+  }
+
+  void setrej_nn_accept() { // NN Flipped a char
+    set_flag(R_NN_ACCEPT);
+  }
+
+  void setrej_mm_accept() { // Matrix matcher
+    set_flag(R_MM_ACCEPT);
+  }
+
+  void setrej_quality_accept() { // Quality flip a char
+    set_flag(R_QUALITY_ACCEPT);
+  }
+
+  void setrej_minimal_rej_accept() {
+    // Accept all except blank
+    set_flag(R_MINIMAL_REJ_ACCEPT);
+  }

   bool accepted() const { // Is char accepted?
     return !rejected();
   }

-  // potential rej?
-  bool accept_if_good_quality() const;
-
   bool recoverable() const {
     return (rejected() && !perm_rejected());
   }

-  void setrej_tess_failure(); // Tess generated blank
-  void setrej_small_xht();    // Small xht char/wd
-  void setrej_edge_char();    // Close to image edge
-  void setrej_1Il_conflict(); // Initial reject map
-  void setrej_postNN_1Il();   // 1Il after NN
-  void setrej_rej_cblob();    // Insert duff blob
-  void setrej_mm_reject();    // Matrix matcher
-                              // Odd repeated char
-  void setrej_bad_repetition();
-  void setrej_poor_match(); // Failed Rays heuristic
-                            // TEMP reject_word
-  void setrej_not_tess_accepted();
-  // TEMP reject_word
-  void setrej_contains_blanks();
-  void setrej_bad_permuter();  // POTENTIAL reject_word
-  void setrej_hyphen();        // PostNN dubious hyph or .
-  void setrej_dubious();       // PostNN dubious limit
-  void setrej_no_alphanums();  // TEMP reject_word
-  void setrej_mostly_rej();    // TEMP reject_word
-  void setrej_xht_fixup();     // xht fixup
-  void setrej_bad_quality();   // TEMP reject_word
-  void setrej_doc_rej();       // TEMP reject_word
-  void setrej_block_rej();     // TEMP reject_word
-  void setrej_row_rej();       // TEMP reject_word
-  void setrej_unlv_rej();      // TEMP reject_word
-  void setrej_nn_accept();     // NN Flipped a char
-  void setrej_hyphen_accept(); // Good aspect ratio
-  void setrej_mm_accept();     // Matrix matcher
-                               // Quality flip a char
-  void setrej_quality_accept();
-  // Accept all except blank
-  void setrej_minimal_rej_accept();
-
   void full_print(FILE *fp) const;
 };