Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use inline to replace extern global constants #1316

Merged
merged 2 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/config/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@
#include "server/server.h"
#include "status.h"

const char *kDefaultNamespace = "__namespace";
const char *kDefaultBindAddress = "127.0.0.1";
constexpr const char *kDefaultBindAddress = "127.0.0.1";

const char *errBlobDbNotEnabled = "Must set rocksdb.enable_blob_files to yes first.";
const char *errLevelCompactionDynamicLevelBytesNotSet =
constexpr const char *errBlobDbNotEnabled = "Must set rocksdb.enable_blob_files to yes first.";
constexpr const char *errLevelCompactionDynamicLevelBytesNotSet =
"Must set rocksdb.level_compaction_dynamic_level_bytes yes first.";

configEnum compression_types[] = {
Expand Down
2 changes: 1 addition & 1 deletion src/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ constexpr const size_t MiB = 1024L * KiB;
constexpr const size_t GiB = 1024L * MiB;
constexpr const uint32_t kDefaultPort = 6666;

extern const char *kDefaultNamespace;
constexpr const char *kDefaultNamespace = "__namespace";

struct CompactionCheckerRange {
public:
Expand Down
4 changes: 1 addition & 3 deletions src/storage/redis_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ const int VersionCounterBits = 11;

static std::atomic<uint64_t> version_counter_ = {0};

const char *kErrMsgWrongType = "WRONGTYPE Operation against a key holding the wrong kind of value";
const char *kErrMsgKeyExpired = "the key was expired";
const char *kErrMetadataTooShort = "metadata is too short";
constexpr const char *kErrMetadataTooShort = "metadata is too short";

InternalKey::InternalKey(Slice input, bool slot_id_encoded) : slot_id_encoded_(slot_id_encoded) {
uint32_t key_size = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/storage/redis_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ enum RedisCommand {
const std::vector<std::string> RedisTypeNames = {"none", "string", "hash", "list", "set",
"zset", "bitmap", "sortedint", "stream"};

extern const char *kErrMsgWrongType;
extern const char *kErrMsgKeyExpired;
constexpr const char *kErrMsgWrongType = "WRONGTYPE Operation against a key holding the wrong kind of value";
constexpr const char *kErrMsgKeyExpired = "the key was expired";

using rocksdb::Slice;

Expand Down
13 changes: 1 addition & 12 deletions src/storage/storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,7 @@

namespace Engine {

const char *kPubSubColumnFamilyName = "pubsub";
const char *kZSetScoreColumnFamilyName = "zset_score";
const char *kMetadataColumnFamilyName = "metadata";
const char *kSubkeyColumnFamilyName = "default";
const char *kPropagateColumnFamilyName = "propagate";
const char *kStreamColumnFamilyName = "stream";

const char *kPropagateScriptCommand = "script";

const char *kLuaFunctionPrefix = "lua_f_";

const char *kReplicationIdKey = "replication_id_";
constexpr const char *kReplicationIdKey = "replication_id_";

const int64_t kIORateLimitMaxMb = 1024000;

Expand Down
16 changes: 8 additions & 8 deletions src/storage/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ enum ColumnFamilyID {

namespace Engine {

extern const char *kPubSubColumnFamilyName;
extern const char *kZSetScoreColumnFamilyName;
extern const char *kMetadataColumnFamilyName;
extern const char *kSubkeyColumnFamilyName;
extern const char *kPropagateColumnFamilyName;
extern const char *kStreamColumnFamilyName;
constexpr const char *kPubSubColumnFamilyName = "pubsub";
constexpr const char *kZSetScoreColumnFamilyName = "zset_score";
constexpr const char *kMetadataColumnFamilyName = "metadata";
constexpr const char *kSubkeyColumnFamilyName = "default";
constexpr const char *kPropagateColumnFamilyName = "propagate";
constexpr const char *kStreamColumnFamilyName = "stream";

extern const char *kPropagateScriptCommand;
constexpr const char *kPropagateScriptCommand = "script";

extern const char *kLuaFunctionPrefix;
constexpr const char *kLuaFunctionPrefix = "lua_f_";

class Storage {
public:
Expand Down
2 changes: 1 addition & 1 deletion src/storage/table_properties_collector.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ class CompactOnExpiredTableCollectorFactory : public rocksdb::TablePropertiesCol
float trigger_threshold_ = 0.3;
};

extern std::shared_ptr<CompactOnExpiredTableCollectorFactory> NewCompactOnExpiredTableCollectorFactory(
std::shared_ptr<CompactOnExpiredTableCollectorFactory> NewCompactOnExpiredTableCollectorFactory(
const std::string &cf_name, float trigger_threshold);