src: Simplify function parameter using StringRef

This commit is contained in:
Tatsuhiro Tsujikawa 2016-03-04 00:38:43 +09:00
parent 3f2b54cfc4
commit e302cc9c16
8 changed files with 10 additions and 18 deletions

View File

@ -1848,11 +1848,10 @@ bool Http2Upstream::push_enabled() const {
get_config()->http2_proxy);
}
int Http2Upstream::initiate_push(Downstream *downstream, const char *uri,
size_t len) {
int Http2Upstream::initiate_push(Downstream *downstream, const StringRef &uri) {
int rv;
if (len == 0 || !push_enabled() || (downstream->get_stream_id() % 2)) {
if (uri.empty() || !push_enabled() || (downstream->get_stream_id() % 2)) {
return 0;
}
@ -1866,8 +1865,7 @@ int Http2Upstream::initiate_push(Downstream *downstream, const char *uri,
const std::string *scheme_ptr, *authority_ptr;
std::string scheme, authority, path;
rv = http2::construct_push_component(scheme, authority, path, base,
StringRef{uri, len});
rv = http2::construct_push_component(scheme, authority, path, base, uri);
if (rv != 0) {
return -1;
}

View File

@ -81,8 +81,7 @@ public:
virtual int on_downstream_reset(bool no_retry);
virtual int send_reply(Downstream *downstream, const uint8_t *body,
size_t bodylen);
virtual int initiate_push(Downstream *downstream, const char *uri,
size_t len);
virtual int initiate_push(Downstream *downstream, const StringRef &uri);
virtual int response_riovec(struct iovec *iov, int iovcnt) const;
virtual void response_drain(size_t n);
virtual bool response_empty() const;

View File

@ -1153,8 +1153,7 @@ fail:
return 0;
}
int HttpsUpstream::initiate_push(Downstream *downstream, const char *uri,
size_t len) {
int HttpsUpstream::initiate_push(Downstream *downstream, const StringRef &uri) {
return 0;
}

View File

@ -76,8 +76,7 @@ public:
virtual int on_downstream_reset(bool no_retry);
virtual int send_reply(Downstream *downstream, const uint8_t *body,
size_t bodylen);
virtual int initiate_push(Downstream *downstream, const char *uri,
size_t len);
virtual int initiate_push(Downstream *downstream, const StringRef &uri);
virtual int response_riovec(struct iovec *iov, int iovcnt) const;
virtual void response_drain(size_t n);
virtual bool response_empty() const;

View File

@ -291,7 +291,7 @@ mrb_value request_push(mrb_state *mrb, mrb_value self) {
mrb_int len;
mrb_get_args(mrb, "s", &uri, &len);
upstream->initiate_push(downstream, uri, len);
upstream->initiate_push(downstream, StringRef{uri, static_cast<size_t>(len)});
return mrb_nil_value();
}

View File

@ -1252,8 +1252,7 @@ int SpdyUpstream::on_downstream_reset(bool no_retry) {
return 0;
}
int SpdyUpstream::initiate_push(Downstream *downstream, const char *uri,
size_t len) {
int SpdyUpstream::initiate_push(Downstream *downstream, const StringRef &uri) {
return 0;
}

View File

@ -76,8 +76,7 @@ public:
virtual int send_reply(Downstream *downstream, const uint8_t *body,
size_t bodylen);
virtual int initiate_push(Downstream *downstream, const char *uri,
size_t len);
virtual int initiate_push(Downstream *downstream, const StringRef &uri);
virtual int response_riovec(struct iovec *iov, int iovcnt) const;
virtual void response_drain(size_t n);
virtual bool response_empty() const;

View File

@ -68,8 +68,7 @@ public:
virtual int send_reply(Downstream *downstream, const uint8_t *body,
size_t bodylen) = 0;
virtual int initiate_push(Downstream *downstream, const char *uri,
size_t len) = 0;
virtual int initiate_push(Downstream *downstream, const StringRef &uri) = 0;
// Fills response data in |iov| whose capacity is |iovcnt|. Returns
// the number of iovs filled.