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

优化static const 变量,减少代码量 #450

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 0 additions & 6 deletions muduo/net/Channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,9 @@

#include <sstream>

#include <poll.h>

using namespace muduo;
using namespace muduo::net;

const int Channel::kNoneEvent = 0;
const int Channel::kReadEvent = POLLIN | POLLPRI;
const int Channel::kWriteEvent = POLLOUT;

Channel::Channel(EventLoop* loop, int fd__)
: loop_(loop),
fd_(fd__),
Expand Down
7 changes: 4 additions & 3 deletions muduo/net/Channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <functional>
#include <memory>
#include <poll.h>

namespace muduo
{
Expand Down Expand Up @@ -86,9 +87,9 @@ class Channel : noncopyable
void update();
void handleEventWithGuard(Timestamp receiveTime);

static const int kNoneEvent;
static const int kReadEvent;
static const int kWriteEvent;
static constexpr int kNoneEvent = 0;
static constexpr int kReadEvent = POLLIN | POLLPRI;
static constexpr int kWriteEvent = POLLOUT;

EventLoop* loop_;
const int fd_;
Expand Down