Skip to content

Commit c8c66aa

Browse files
authored
[ML] Make constants truly constant (#411)
Follow-on to #102. Fixing more places where pointers intended to be immutable could be changed to a point at a different constant. Backport of #409
1 parent bd953b4 commit c8c66aa

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

lib/api/CDataFrameAnalysisSpecification.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ TRunnerFactoryUPtrVec analysisFactories() {
3636
}
3737

3838
// These must be consistent with Java names.
39-
const char* ROWS{"rows"};
40-
const char* COLS{"cols"};
41-
const char* MEMORY_LIMIT{"memory_limit"};
42-
const char* THREADS{"threads"};
43-
const char* TEMPORARY_DIRECTORY{"temp_dir"};
44-
const char* ANALYSIS{"analysis"};
45-
const char* NAME{"name"};
46-
const char* PARAMETERS{"parameters"};
47-
48-
const char* VALID_MEMBER_NAMES[]{ROWS, COLS, MEMORY_LIMIT, THREADS, ANALYSIS};
39+
const char* const ROWS{"rows"};
40+
const char* const COLS{"cols"};
41+
const char* const MEMORY_LIMIT{"memory_limit"};
42+
const char* const THREADS{"threads"};
43+
const char* const TEMPORARY_DIRECTORY{"temp_dir"};
44+
const char* const ANALYSIS{"analysis"};
45+
const char* const NAME{"name"};
46+
const char* const PARAMETERS{"parameters"};
47+
48+
const char* const VALID_MEMBER_NAMES[]{ROWS, COLS, MEMORY_LIMIT, THREADS, ANALYSIS};
4949

5050
template<typename MEMBER>
5151
bool isValidMember(const MEMBER& member) {

lib/api/CDataFrameOutliersRunner.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ namespace ml {
2727
namespace api {
2828
namespace {
2929
// Configuration
30-
const char* NUMBER_NEIGHBOURS{"number_neighbours"};
31-
const char* METHOD{"method"};
32-
const char* LOF{"lof"};
33-
const char* LDOF{"ldof"};
34-
const char* DISTANCE_KTH_NN{"distance_kth_nn"};
35-
const char* DISTANCE_KNN{"distance_knn"};
36-
const char* VALID_MEMBER_NAMES[]{NUMBER_NEIGHBOURS, METHOD};
30+
const char* const NUMBER_NEIGHBOURS{"number_neighbours"};
31+
const char* const METHOD{"method"};
32+
const char* const LOF{"lof"};
33+
const char* const LDOF{"ldof"};
34+
const char* const DISTANCE_KTH_NN{"distance_kth_nn"};
35+
const char* const DISTANCE_KNN{"distance_knn"};
36+
const char* const VALID_MEMBER_NAMES[]{NUMBER_NEIGHBOURS, METHOD};
3737

3838
// Output
39-
const char* OUTLIER_SCORE{"outlier_score"};
39+
const char* const OUTLIER_SCORE{"outlier_score"};
4040

4141
template<typename MEMBER>
4242
bool isValidMember(const MEMBER& member) {

lib/config/CTools.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ std::string CTools::prettyPrint(double d) {
8585
}
8686

8787
std::string CTools::prettyPrint(core_t::TTime time) {
88-
static const char* SUFFIXES[] = {" week", " day", " hr", " min", " sec"};
88+
static const char* const SUFFIXES[] = {" week", " day", " hr", " min", " sec"};
8989

9090
std::string result;
9191
core_t::TTime intervals[] = {(time / 604800), (time / 86400) % 7,

0 commit comments

Comments
 (0)