src: Use std::copy_n
This commit is contained in:
parent
b165775811
commit
4956bdc4da
|
@ -211,7 +211,7 @@ public:
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
if (buf_) {
|
if (buf_) {
|
||||||
std::copy(buf_, buf_ + buflen_, std::begin(buffer));
|
std::copy_n(buf_, buflen_, std::begin(buffer));
|
||||||
|
|
||||||
len += buflen_;
|
len += buflen_;
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ public:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::copy(data, data + nread, std::begin(buffer) + len);
|
std::copy_n(data, nread, std::begin(buffer) + len);
|
||||||
|
|
||||||
len += nread;
|
len += nread;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ template <size_t N> struct Buffer {
|
||||||
size_t write(const void *src, size_t count) {
|
size_t write(const void *src, size_t count) {
|
||||||
count = std::min(count, wleft());
|
count = std::min(count, wleft());
|
||||||
auto p = static_cast<const uint8_t *>(src);
|
auto p = static_cast<const uint8_t *>(src);
|
||||||
last = std::copy(p, p + count, last);
|
last = std::copy_n(p, count, last);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
size_t write(size_t count) {
|
size_t write(size_t count) {
|
||||||
|
|
|
@ -1204,7 +1204,7 @@ int main(int argc, char **argv) {
|
||||||
auto proto_list = util::get_default_alpn();
|
auto proto_list = util::get_default_alpn();
|
||||||
#ifdef HAVE_SPDYLAY
|
#ifdef HAVE_SPDYLAY
|
||||||
static const char spdy_proto_list[] = "\x8spdy/3.1\x6spdy/3\x6spdy/2";
|
static const char spdy_proto_list[] = "\x8spdy/3.1\x6spdy/3\x6spdy/2";
|
||||||
std::copy(spdy_proto_list, spdy_proto_list + sizeof(spdy_proto_list) - 1,
|
std::copy_n(spdy_proto_list, sizeof(spdy_proto_list) - 1,
|
||||||
std::back_inserter(proto_list));
|
std::back_inserter(proto_list));
|
||||||
#endif // HAVE_SPDYLAY
|
#endif // HAVE_SPDYLAY
|
||||||
SSL_CTX_set_alpn_protos(ssl_ctx, proto_list.data(), proto_list.size());
|
SSL_CTX_set_alpn_protos(ssl_ctx, proto_list.data(), proto_list.size());
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "template.h"
|
#include "template.h"
|
||||||
|
|
||||||
|
@ -134,7 +135,7 @@ template <typename Memchunk> struct Memchunks {
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
auto n = std::min(static_cast<size_t>(last - first), tail->left());
|
auto n = std::min(static_cast<size_t>(last - first), tail->left());
|
||||||
tail->last = std::copy(first, first + n, tail->last);
|
tail->last = std::copy_n(first, n, tail->last);
|
||||||
first += n;
|
first += n;
|
||||||
len += n;
|
len += n;
|
||||||
if (first == last) {
|
if (first == last) {
|
||||||
|
@ -165,7 +166,7 @@ template <typename Memchunk> struct Memchunks {
|
||||||
auto n = std::min(static_cast<size_t>(last - first), m->len());
|
auto n = std::min(static_cast<size_t>(last - first), m->len());
|
||||||
|
|
||||||
assert(m->len());
|
assert(m->len());
|
||||||
first = std::copy(m->pos, m->pos + n, first);
|
first = std::copy_n(m->pos, n, first);
|
||||||
m->pos += n;
|
m->pos += n;
|
||||||
len -= n;
|
len -= n;
|
||||||
if (m->len() > 0) {
|
if (m->len() > 0) {
|
||||||
|
|
|
@ -195,13 +195,13 @@ std::string http_date(time_t t) {
|
||||||
auto p = std::begin(res);
|
auto p = std::begin(res);
|
||||||
|
|
||||||
auto s = DAY_OF_WEEK[tms.tm_wday];
|
auto s = DAY_OF_WEEK[tms.tm_wday];
|
||||||
p = std::copy(s, s + 3, p);
|
p = std::copy_n(s, 3, p);
|
||||||
*p++ = ',';
|
*p++ = ',';
|
||||||
*p++ = ' ';
|
*p++ = ' ';
|
||||||
p = cpydig(p, tms.tm_mday, 2);
|
p = cpydig(p, tms.tm_mday, 2);
|
||||||
*p++ = ' ';
|
*p++ = ' ';
|
||||||
s = MONTH[tms.tm_mon];
|
s = MONTH[tms.tm_mon];
|
||||||
p = std::copy(s, s + 3, p);
|
p = std::copy_n(s, 3, p);
|
||||||
*p++ = ' ';
|
*p++ = ' ';
|
||||||
p = cpydig(p, tms.tm_year + 1900, 4);
|
p = cpydig(p, tms.tm_year + 1900, 4);
|
||||||
*p++ = ' ';
|
*p++ = ' ';
|
||||||
|
@ -211,7 +211,7 @@ std::string http_date(time_t t) {
|
||||||
*p++ = ':';
|
*p++ = ':';
|
||||||
p = cpydig(p, tms.tm_sec, 2);
|
p = cpydig(p, tms.tm_sec, 2);
|
||||||
s = " GMT";
|
s = " GMT";
|
||||||
p = std::copy(s, s + 4, p);
|
p = std::copy_n(s, 4, p);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ std::string common_log_date(time_t t) {
|
||||||
p = cpydig(p, tms.tm_mday, 2);
|
p = cpydig(p, tms.tm_mday, 2);
|
||||||
*p++ = '/';
|
*p++ = '/';
|
||||||
auto s = MONTH[tms.tm_mon];
|
auto s = MONTH[tms.tm_mon];
|
||||||
p = std::copy(s, s + 3, p);
|
p = std::copy_n(s, 3, p);
|
||||||
*p++ = '/';
|
*p++ = '/';
|
||||||
p = cpydig(p, tms.tm_year + 1900, 4);
|
p = cpydig(p, tms.tm_year + 1900, 4);
|
||||||
*p++ = ':';
|
*p++ = ':';
|
||||||
|
|
Loading…
Reference in New Issue