nghttp: next_weight_idx is enough to be an local variable

This commit is contained in:
Tatsuhiro Tsujikawa 2016-07-29 19:36:05 +09:00
parent 3c1c2c4aad
commit af5b354685
2 changed files with 6 additions and 7 deletions

View File

@ -96,7 +96,6 @@ Config::Config()
: header_table_size(-1),
min_header_table_size(std::numeric_limits<uint32_t>::max()),
padding(0),
next_weight_idx(0),
max_concurrent_streams(100),
peer_max_concurrent_streams(100),
multiply(1),
@ -2484,16 +2483,19 @@ int run(char **uris, int n) {
}
std::vector<std::tuple<std::string, nghttp2_data_provider *, int64_t,
int32_t>> requests;
size_t next_weight_idx = 0;
for (int i = 0; i < n; ++i) {
http_parser_url u{};
auto uri = strip_fragment(uris[i]);
if (http_parser_parse_url(uri.c_str(), uri.size(), 0, &u) != 0) {
++config.next_weight_idx;
++next_weight_idx;
std::cerr << "[ERROR] Could not parse URI " << uri << std::endl;
continue;
}
if (!util::has_uri_field(u, UF_SCHEMA)) {
++config.next_weight_idx;
++next_weight_idx;
std::cerr << "[ERROR] URI " << uri << " does not have scheme part"
<< std::endl;
continue;
@ -2516,8 +2518,7 @@ int run(char **uris, int n) {
prev_port = port;
}
requests.emplace_back(uri, data_fd == -1 ? nullptr : &data_prd,
data_stat.st_size,
config.weight[config.next_weight_idx++]);
data_stat.st_size, config.weight[next_weight_idx++]);
}
if (!requests.empty()) {
if (communicate(prev_scheme, prev_host, prev_port, std::move(requests),

View File

@ -73,8 +73,6 @@ struct Config {
int64_t header_table_size;
int64_t min_header_table_size;
size_t padding;
// the next index into weight.
size_t next_weight_idx;
size_t max_concurrent_streams;
ssize_t peer_max_concurrent_streams;
int multiply;