This is an automated email from the ASF dual-hosted git repository.
tison pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/incubator-kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new f79e86a6 Replace c-style typedef with direct definition or using
(#1143)
f79e86a6 is described below
commit f79e86a66362745b151d149a455403f2f85dd70f
Author: Twice <[email protected]>
AuthorDate: Sat Nov 26 17:01:49 2022 +0800
Replace c-style typedef with direct definition or using (#1143)
---
src/cluster/cluster.h | 2 +-
src/cluster/replication.h | 2 +-
src/common/sha1.h | 4 ++--
src/server/redis_connection.h | 2 +-
src/server/server.h | 4 ++--
src/types/geohash.h | 6 ++---
src/types/redis_geo.h | 4 ++--
src/types/redis_hash.h | 4 ++--
src/types/redis_sortedint.h | 21 ++++++-----------
src/types/redis_zset.h | 54 ++++++++++++++++---------------------------
10 files changed, 41 insertions(+), 62 deletions(-)
diff --git a/src/cluster/cluster.h b/src/cluster/cluster.h
index 7cac6fba..7651a9a0 100644
--- a/src/cluster/cluster.h
+++ b/src/cluster/cluster.h
@@ -69,7 +69,7 @@ struct SlotInfo {
std::vector<NodeInfo> nodes;
};
-typedef std::unordered_map<std::string, std::shared_ptr<ClusterNode>>
ClusterNodes;
+using ClusterNodes = std::unordered_map<std::string,
std::shared_ptr<ClusterNode>>;
class Server;
diff --git a/src/cluster/replication.h b/src/cluster/replication.h
index 64841266..a96cf4c1 100644
--- a/src/cluster/replication.h
+++ b/src/cluster/replication.h
@@ -55,7 +55,7 @@ enum WriteBatchType {
kBatchTypeStream,
};
-typedef std::function<void(const std::string, const uint32_t)>
fetch_file_callback;
+using fetch_file_callback = std::function<void(const std::string, const
uint32_t)>;
class FeedSlaveThread {
public:
diff --git a/src/common/sha1.h b/src/common/sha1.h
index ce162d85..88124dce 100644
--- a/src/common/sha1.h
+++ b/src/common/sha1.h
@@ -29,11 +29,11 @@ By Steve Reid <[email protected]>
#include <cstdint>
-typedef struct {
+struct SHA1_CTX {
uint32_t state[5];
uint32_t count[2];
unsigned char buffer[64];
-} SHA1_CTX;
+};
void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
void SHA1Init(SHA1_CTX* context);
diff --git a/src/server/redis_connection.h b/src/server/redis_connection.h
index d07c26fb..b9522532 100644
--- a/src/server/redis_connection.h
+++ b/src/server/redis_connection.h
@@ -56,7 +56,7 @@ class Connection {
void SendFile(int fd);
std::string ToString();
- typedef std::function<void(std::string, int)> unsubscribe_callback;
+ using unsubscribe_callback = std::function<void(std::string, int)>;
void SubscribeChannel(const std::string &channel);
void UnSubscribeChannel(const std::string &channel);
void UnSubscribeAll(const unsubscribe_callback &reply = nullptr);
diff --git a/src/server/server.h b/src/server/server.h
index 7c75adeb..a167be18 100644
--- a/src/server/server.h
+++ b/src/server/server.h
@@ -67,10 +67,10 @@ struct StreamConsumer {
: owner(w), fd(fd), ns(std::move(ns)), last_consumed_id(id) {}
};
-typedef struct {
+struct ChannelSubscribeNum {
std::string channel;
size_t subscribe_num;
-} ChannelSubscribeNum;
+};
enum SlowLog {
kSlowLogMaxArgc = 32,
diff --git a/src/types/geohash.h b/src/types/geohash.h
index f2762263..17f8226d 100644
--- a/src/types/geohash.h
+++ b/src/types/geohash.h
@@ -76,7 +76,7 @@
#define GISZERO(s) (!s.bits && !s.step)
#define GISNOTZERO(s) (s.bits || s.step)
-typedef enum {
+enum GeoDirection {
GEOHASH_NORTH = 0,
GEOHASH_EAST,
GEOHASH_WEST,
@@ -85,7 +85,7 @@ typedef enum {
GEOHASH_SOUTH_EAST,
GEOHASH_NORT_WEST,
GEOHASH_NORT_EAST
-} GeoDirection;
+};
struct GeoHashBits {
uint64_t bits = 0;
@@ -114,7 +114,7 @@ struct GeoHashNeighbors {
GeoHashBits south_west;
};
-typedef uint64_t GeoHashFix52Bits;
+using GeoHashFix52Bits = uint64_t;
struct GeoHashRadius {
GeoHashBits hash;
diff --git a/src/types/redis_geo.h b/src/types/redis_geo.h
index 1119d51f..8e7fb915 100644
--- a/src/types/redis_geo.h
+++ b/src/types/redis_geo.h
@@ -44,13 +44,13 @@ enum DistanceSort {
};
// Structures represent points and array of points on the earth.
-typedef struct GeoPoint {
+struct GeoPoint {
double longitude;
double latitude;
std::string member;
double dist;
double score;
-} GeoPoint;
+};
namespace Redis {
diff --git a/src/types/redis_hash.h b/src/types/redis_hash.h
index e5075303..0ed4c972 100644
--- a/src/types/redis_hash.h
+++ b/src/types/redis_hash.h
@@ -29,10 +29,10 @@
#include "storage/redis_db.h"
#include "storage/redis_metadata.h"
-typedef struct FieldValue {
+struct FieldValue {
std::string field;
std::string value;
-} FieldValue;
+};
enum class HashFetchType { kAll = 0, kOnlyKey = 1, kOnlyValue = 2 };
diff --git a/src/types/redis_sortedint.h b/src/types/redis_sortedint.h
index e37d8522..7011bbbe 100644
--- a/src/types/redis_sortedint.h
+++ b/src/types/redis_sortedint.h
@@ -27,20 +27,13 @@
#include "storage/redis_db.h"
#include "storage/redis_metadata.h"
-typedef struct SortedintRangeSpec {
- uint64_t min, max;
- bool minex, maxex; /* are min or max exclusive */
- int offset, count;
- bool reversed;
- SortedintRangeSpec() {
- min = std::numeric_limits<uint64_t>::lowest();
- max = std::numeric_limits<uint64_t>::max();
- minex = maxex = false;
- offset = -1;
- count = -1;
- reversed = false;
- }
-} SortedintRangeSpec;
+struct SortedintRangeSpec {
+ uint64_t min = std::numeric_limits<uint64_t>::lowest(), max =
std::numeric_limits<uint64_t>::max();
+ bool minex = false, maxex = false; /* are min or max exclusive */
+ int offset = -1, count = -1;
+ bool reversed = false;
+ SortedintRangeSpec() = default;
+};
namespace Redis {
diff --git a/src/types/redis_zset.h b/src/types/redis_zset.h
index d1699997..ac2625de 100644
--- a/src/types/redis_zset.h
+++ b/src/types/redis_zset.h
@@ -35,46 +35,32 @@ const double kMinScore =
(std::numeric_limits<float>::is_iec559 ? -std::numeric_
const double kMaxScore = (std::numeric_limits<float>::is_iec559 ?
std::numeric_limits<double>::infinity()
:
std::numeric_limits<double>::max());
-typedef struct ZRangeSpec {
- double min, max;
- bool minex, maxex; /* are min or max exclusive */
- int offset, count;
- bool removed, reversed;
- ZRangeSpec() {
- min = kMinScore;
- max = kMaxScore;
- minex = maxex = false;
- offset = -1;
- count = -1;
- removed = reversed = false;
- }
-} ZRangeSpec;
-
-typedef struct ZRangeLexSpec {
+struct ZRangeSpec {
+ double min = kMinScore, max = kMaxScore;
+ bool minex = false, maxex = false; /* are min or max exclusive */
+ int offset = -1, count = -1;
+ bool removed = false, reversed = false;
+ ZRangeSpec() = default;
+};
+
+struct ZRangeLexSpec {
std::string min, max;
- bool minex, maxex; /* are min or max exclusive */
- bool max_infinite; /* are max infinite */
- int offset, count;
- bool removed, reversed;
- ZRangeLexSpec() {
- minex = maxex = false;
- max_infinite = false;
- offset = -1;
- count = -1;
- removed = false;
- reversed = false;
- }
-} ZRangeLexSpec;
-
-typedef struct KeyWeight {
+ bool minex = false, maxex = false; /* are min or max exclusive */
+ bool max_infinite = false; /* are max infinite */
+ int offset = -1, count = -1;
+ bool removed = false, reversed = false;
+ ZRangeLexSpec() = default;
+};
+
+struct KeyWeight {
std::string key;
double weight;
-} KeyWeight;
+};
-typedef struct {
+struct MemberScore {
std::string member;
double score;
-} MemberScore;
+};
enum ZSetFlags {
kZSetIncr = 1,