@@ -171,12 +171,11 @@ void HostRedirector::initAndStart(const Json::Value &config)
171
171
const auto &redirectFromValue = rules[redirectToStr];
172
172
173
173
auto toIdx = rulesTo_.size ();
174
- rulesTo_.push_back ({
175
- std::move (redirectToHost.empty () && pathIdx != 0
176
- ? redirectToStr
177
- : redirectToHost),
178
- std::move (redirectToPath),
179
- });
174
+ rulesTo_.emplace_back (std::move (redirectToHost.empty () &&
175
+ pathIdx != 0
176
+ ? redirectToStr
177
+ : redirectToHost),
178
+ std::move (redirectToPath));
180
179
181
180
if (redirectFromValue.isArray ())
182
181
{
@@ -210,12 +209,10 @@ void HostRedirector::initAndStart(const Json::Value &config)
210
209
: redirectFromHost;
211
210
if (!fromHost.empty ())
212
211
doHostLookup_ = true ; // We have hosts in lookup rules
213
- rulesFromData_.push_back ({
214
- std::move (fromHost),
215
- std::move (redirectFromPath),
216
- isWildcard,
217
- toIdx,
218
- });
212
+ rulesFromData_.emplace_back (std::move (fromHost),
213
+ std::move (redirectFromPath),
214
+ isWildcard,
215
+ toIdx);
219
216
}
220
217
}
221
218
// TODO: This commented block can be used to support {from: to}
@@ -239,11 +236,11 @@ void HostRedirector::initAndStart(const Json::Value &config)
239
236
for (const auto &redirectFrom : rulesFromData_)
240
237
{
241
238
const auto &path = redirectFrom.path ;
242
- auto &rule = rulesFrom_[redirectFrom.host ];
243
239
if (path == " /" ) // Root rules are part of the host group
244
240
continue ;
245
241
246
242
auto len = path.size ();
243
+ auto &rule = rulesFrom_[redirectFrom.host ];
247
244
if (len < rule.maxPathLen )
248
245
rule.maxPathLen = len;
249
246
}
@@ -284,7 +281,7 @@ void HostRedirector::initAndStart(const Json::Value &config)
284
281
}
285
282
286
283
auto &leaf = leafs[group];
287
- leaf.fromData .push_back (&redirectFrom);
284
+ leaf.fromData .emplace_back (&redirectFrom);
288
285
leaf.maxPathLen = maxLen;
289
286
}
290
287
@@ -331,7 +328,7 @@ void HostRedirector::initAndStart(const Json::Value &config)
331
328
}
332
329
333
330
auto &leaf = leafsBackbuffer[childGroup];
334
- leaf.fromData .push_back (redirectFrom);
331
+ leaf.fromData .emplace_back (redirectFrom);
335
332
leaf.maxPathLen = maxIdx;
336
333
}
337
334
}
0 commit comments