From 23d05a5e1be457d77f9bbd9354c8830cc9f8c860 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 20 May 2019 22:24:28 +0200 Subject: [PATCH] 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 --- src/classify/featdefs.cpp | 8 ++++---- src/classify/featdefs.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/classify/featdefs.cpp b/src/classify/featdefs.cpp index f1068c1228..139e3bfb17 100644 --- a/src/classify/featdefs.cpp +++ b/src/classify/featdefs.cpp @@ -29,10 +29,10 @@ /*----------------------------------------------------------------------------- Global Data Definitions and Declarations -----------------------------------------------------------------------------*/ -const char* kMicroFeatureType = "mf"; -const char* kCNFeatureType = "cn"; -const char* kIntFeatureType = "if"; -const char* kGeoFeatureType = "tb"; +constexpr const char* kMicroFeatureType = "mf"; +constexpr const char* kCNFeatureType = "cn"; +constexpr const char* kIntFeatureType = "if"; +constexpr const char* kGeoFeatureType = "tb"; // Define all of the parameters for the MicroFeature type. StartParamDesc(MicroFeatureParams) diff --git a/src/classify/featdefs.h b/src/classify/featdefs.h index 6996898cb5..15228660d1 100644 --- a/src/classify/featdefs.h +++ b/src/classify/featdefs.h @@ -26,10 +26,10 @@ /* Enumerate the different types of features currently defined. */ #define NUM_FEATURE_TYPES 4 -extern const char* kMicroFeatureType; -extern const char* kCNFeatureType; -extern const char* kIntFeatureType; -extern const char* kGeoFeatureType; +extern const char* const kMicroFeatureType; +extern const char* const kCNFeatureType; +extern const char* const kIntFeatureType; +extern const char* const kGeoFeatureType; /* A character is described by multiple sets of extracted features. Each set contains a number of features of a particular type, for example, a