Remove enum usages for static constants creation.
GitOrigin-RevId: 2a88fd2cd961398a09403fe35a15ae56372a44f8
This commit is contained in:
parent
ea4841a37c
commit
0cf4fea1ff
@ -40,8 +40,8 @@ class IostreamWriteBench : public td::Benchmark {
|
||||
protected:
|
||||
std::string file_name_;
|
||||
std::ofstream stream;
|
||||
enum { buffer_size = 1 << 20 };
|
||||
char buffer[buffer_size];
|
||||
static constexpr std::size_t BUFFER_SIZE = 1 << 20;
|
||||
char buffer[BUFFER_SIZE];
|
||||
|
||||
public:
|
||||
std::string get_description() const override {
|
||||
@ -52,7 +52,7 @@ class IostreamWriteBench : public td::Benchmark {
|
||||
file_name_ = create_tmp_file();
|
||||
stream.open(file_name_.c_str());
|
||||
CHECK(stream.is_open());
|
||||
// stream.rdbuf()->pubsetbuf(buffer, buffer_size);
|
||||
// stream.rdbuf()->pubsetbuf(buffer, BUFFER_SIZE);
|
||||
}
|
||||
|
||||
void run(int n) override {
|
||||
@ -71,8 +71,8 @@ class FILEWriteBench : public td::Benchmark {
|
||||
protected:
|
||||
std::string file_name_;
|
||||
FILE *file;
|
||||
enum { buffer_size = 1 << 20 };
|
||||
char buffer[buffer_size];
|
||||
static constexpr std::size_t BUFFER_SIZE = 1 << 20;
|
||||
char buffer[BUFFER_SIZE];
|
||||
|
||||
public:
|
||||
std::string get_description() const override {
|
||||
@ -82,7 +82,7 @@ class FILEWriteBench : public td::Benchmark {
|
||||
void start_up() override {
|
||||
file_name_ = create_tmp_file();
|
||||
file = fopen(file_name_.c_str(), "w");
|
||||
// setvbuf(file, buffer, _IOFBF, buffer_size);
|
||||
// setvbuf(file, buffer, _IOFBF, BUFFER_SIZE);
|
||||
}
|
||||
|
||||
void run(int n) override {
|
||||
@ -123,8 +123,8 @@ class LogWriteBench : public td::Benchmark {
|
||||
std::string file_name_;
|
||||
std::ofstream stream;
|
||||
std::streambuf *old_buf;
|
||||
enum { buffer_size = 1 << 20 };
|
||||
char buffer[buffer_size];
|
||||
static constexpr std::size_t BUFFER_SIZE = 1 << 20;
|
||||
char buffer[BUFFER_SIZE];
|
||||
|
||||
public:
|
||||
std::string get_description() const override {
|
||||
|
@ -837,7 +837,7 @@ class QueueBenchmark : public td::Benchmark {
|
||||
|
||||
template <class QueueT>
|
||||
class RingBenchmark : public td::Benchmark {
|
||||
enum { QN = 504 };
|
||||
static constexpr int QN = 504;
|
||||
|
||||
struct Thread {
|
||||
int int_id;
|
||||
|
@ -66,7 +66,9 @@ class AuthKey {
|
||||
auth_key_.clear();
|
||||
}
|
||||
|
||||
enum : int32 { AUTH_FLAG = 1, WAS_AUTH_FLAG = 2, HAS_CREATED_AT = 4 };
|
||||
static constexpr int32 AUTH_FLAG = 1;
|
||||
static constexpr int32 WAS_AUTH_FLAG = 2;
|
||||
static constexpr int32 HAS_CREATED_AT = 4;
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const {
|
||||
|
@ -64,7 +64,8 @@ class UdpReaderHelper {
|
||||
}
|
||||
|
||||
private:
|
||||
enum : size_t { MAX_PACKET_SIZE = 2048, RESERVED_SIZE = MAX_PACKET_SIZE * 8 };
|
||||
static constexpr size_t MAX_PACKET_SIZE = 2048;
|
||||
static constexpr size_t RESERVED_SIZE = MAX_PACKET_SIZE * 8;
|
||||
UdpMessage message_;
|
||||
BufferSlice buffer_;
|
||||
};
|
||||
@ -98,7 +99,7 @@ class UdpReader {
|
||||
}
|
||||
|
||||
private:
|
||||
enum : size_t { BUFFER_SIZE = 16 };
|
||||
static constexpr size_t BUFFER_SIZE = 16;
|
||||
std::array<UdpSocketFd::InboundMessage, BUFFER_SIZE> messages_;
|
||||
std::array<UdpReaderHelper, BUFFER_SIZE> helpers_;
|
||||
};
|
||||
|
@ -170,7 +170,8 @@ class UdpSocketFdImpl : private Iocp::Callback {
|
||||
UdpMessage to_receive_;
|
||||
WSAMSG receive_message_;
|
||||
UdpSocketReceiveHelper receive_helper_;
|
||||
enum : size_t { MAX_PACKET_SIZE = 2048, RESERVED_SIZE = MAX_PACKET_SIZE * 8 };
|
||||
static constexpr size_t MAX_PACKET_SIZE = 2048;
|
||||
static constexpr size_t RESERVED_SIZE = MAX_PACKET_SIZE * 8;
|
||||
BufferSlice receive_buffer_;
|
||||
|
||||
UdpMessage to_send_;
|
||||
|
Loading…
Reference in New Issue
Block a user