Commit b1cbc632 for tesseract
commit b1cbc632e80b8bdb1841f1f337e28e75631fea85
Author: Stefan Weil <sw@weilnetz.de>
Date: Thu Jun 4 21:40:56 2026 +0200
Use more `constexpr`
Remove ccstruct.cpp which is no longer used.
Assisted-by: OpenCode / BigPickle
Signed-off-by: Stefan Weil <sw@weilnetz.de>
diff --git a/Makefile.am b/Makefile.am
index 4f71f02c..af061b80 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -318,7 +318,6 @@ libtesseract_la_SOURCES += src/ccstruct/blobs.cpp
libtesseract_la_SOURCES += src/ccstruct/blread.cpp
libtesseract_la_SOURCES += src/ccstruct/boxread.cpp
libtesseract_la_SOURCES += src/ccstruct/boxword.cpp
-libtesseract_la_SOURCES += src/ccstruct/ccstruct.cpp
libtesseract_la_SOURCES += src/ccstruct/coutln.cpp
libtesseract_la_SOURCES += src/ccstruct/detlinefit.cpp
libtesseract_la_SOURCES += src/ccstruct/dppoint.cpp
diff --git a/cmake/SourceLists.cmake b/cmake/SourceLists.cmake
index bc8e415f..58238303 100644
--- a/cmake/SourceLists.cmake
+++ b/cmake/SourceLists.cmake
@@ -91,7 +91,6 @@ set(TESSERACT_SRC_CCSTRUCT
src/ccstruct/blread.cpp
src/ccstruct/boxread.cpp
src/ccstruct/boxword.cpp
- src/ccstruct/ccstruct.cpp
src/ccstruct/coutln.cpp
src/ccstruct/detlinefit.cpp
src/ccstruct/dppoint.cpp
diff --git a/src/ccstruct/ccstruct.cpp b/src/ccstruct/ccstruct.cpp
deleted file mode 100644
index 80453f58..00000000
--- a/src/ccstruct/ccstruct.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-///////////////////////////////////////////////////////////////////////
-// File: ccstruct.cpp
-// Description: ccstruct class.
-// Author: Samuel Charron
-//
-// (C) Copyright 2006, Google Inc.
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-///////////////////////////////////////////////////////////////////////
-
-#include "ccstruct.h"
-
-namespace tesseract {
-
-// APPROXIMATIONS of the fractions of the character cell taken by
-// the descenders, ascenders, and x-height.
-const double CCStruct::kDescenderFraction = 0.25;
-const double CCStruct::kXHeightFraction = 0.5;
-const double CCStruct::kAscenderFraction = 0.25;
-const double CCStruct::kXHeightCapRatio =
- CCStruct::kXHeightFraction / (CCStruct::kXHeightFraction + CCStruct::kAscenderFraction);
-
-} // namespace tesseract
diff --git a/src/ccstruct/ccstruct.h b/src/ccstruct/ccstruct.h
index 80dcaac0..218a62f3 100644
--- a/src/ccstruct/ccstruct.h
+++ b/src/ccstruct/ccstruct.h
@@ -28,11 +28,11 @@ public:
// Globally accessible constants.
// APPROXIMATIONS of the fractions of the character cell taken by
// the descenders, ascenders, and x-height.
- static const double kDescenderFraction; // = 0.25;
- static const double kXHeightFraction; // = 0.5;
- static const double kAscenderFraction; // = 0.25;
+ static constexpr double kDescenderFraction = 0.25;
+ static constexpr double kXHeightFraction = 0.5;
+ static constexpr double kAscenderFraction = 0.25;
// Derived value giving the x-height as a fraction of cap-height.
- static const double kXHeightCapRatio; // = XHeight/(XHeight + Ascender).
+ static constexpr double kXHeightCapRatio = kXHeightFraction / (kXHeightFraction + kAscenderFraction);
};
} // namespace tesseract
diff --git a/src/ccstruct/normalis.h b/src/ccstruct/normalis.h
index 5f8bc642..92743b8c 100644
--- a/src/ccstruct/normalis.h
+++ b/src/ccstruct/normalis.h
@@ -29,9 +29,9 @@ struct Pix;
namespace tesseract {
-const int kBlnCellHeight = 256; // Full-height for baseline normalization.
-const int kBlnXHeight = 128; // x-height for baseline normalization.
-const int kBlnBaselineOffset = 64; // offset for baseline normalization.
+constexpr int kBlnCellHeight = 256; // Full-height for baseline normalization.
+constexpr int kBlnXHeight = 128; // x-height for baseline normalization.
+constexpr int kBlnBaselineOffset = 64; // offset for baseline normalization.
class BLOCK;
class FCOORD;