Skip to content

Commit 23d05a5

Browse files
committed
featdefs: Optimize code by using constexpr
This also fixes some warnings from clang++: src/classify/featdefs.cpp:47:15: warning: declaration requires a global constructor [-Wglobal-constructors] src/classify/featdefs.cpp:57:15: warning: declaration requires a global constructor [-Wglobal-constructors] src/classify/featdefs.cpp:66:15: warning: declaration requires a global constructor [-Wglobal-constructors] src/classify/featdefs.cpp:75:15: warning: declaration requires a global constructor [-Wglobal-constructors] Signed-off-by: Stefan Weil <[email protected]>
1 parent 7628112 commit 23d05a5

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/classify/featdefs.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
/*-----------------------------------------------------------------------------
3030
Global Data Definitions and Declarations
3131
-----------------------------------------------------------------------------*/
32-
const char* kMicroFeatureType = "mf";
33-
const char* kCNFeatureType = "cn";
34-
const char* kIntFeatureType = "if";
35-
const char* kGeoFeatureType = "tb";
32+
constexpr const char* kMicroFeatureType = "mf";
33+
constexpr const char* kCNFeatureType = "cn";
34+
constexpr const char* kIntFeatureType = "if";
35+
constexpr const char* kGeoFeatureType = "tb";
3636

3737
// Define all of the parameters for the MicroFeature type.
3838
StartParamDesc(MicroFeatureParams)

src/classify/featdefs.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
/* Enumerate the different types of features currently defined. */
2828
#define NUM_FEATURE_TYPES 4
29-
extern const char* kMicroFeatureType;
30-
extern const char* kCNFeatureType;
31-
extern const char* kIntFeatureType;
32-
extern const char* kGeoFeatureType;
29+
extern const char* const kMicroFeatureType;
30+
extern const char* const kCNFeatureType;
31+
extern const char* const kIntFeatureType;
32+
extern const char* const kGeoFeatureType;
3333

3434
/* A character is described by multiple sets of extracted features. Each
3535
set contains a number of features of a particular type, for example, a

0 commit comments

Comments
 (0)