@@ -20,7 +20,7 @@ const std::string& TCgiParameters::Get(const std::string_view name, size_t numOf
20
20
}
21
21
22
22
bool TCgiParameters::Erase (const std::string_view name, size_t pos) {
23
- const auto pair = equal_range (static_cast <std::string>( name) );
23
+ const auto pair = equal_range (name);
24
24
25
25
for (auto it = pair.first ; it != pair.second ; ++it, --pos) {
26
26
if (0 == pos) {
@@ -33,7 +33,7 @@ bool TCgiParameters::Erase(const std::string_view name, size_t pos) {
33
33
}
34
34
35
35
bool TCgiParameters::Erase (const std::string_view name, const std::string_view val) {
36
- const auto pair = equal_range (static_cast <std::string>( name) );
36
+ const auto pair = equal_range (name);
37
37
38
38
bool found = false ;
39
39
for (auto it = pair.first ; it != pair.second ;) {
@@ -49,7 +49,7 @@ bool TCgiParameters::Erase(const std::string_view name, const std::string_view v
49
49
}
50
50
51
51
bool TCgiParameters::ErasePattern (const std::string_view name, const std::string_view pat) {
52
- const auto pair = equal_range (static_cast <std::string>( name) );
52
+ const auto pair = equal_range (name);
53
53
54
54
bool found = false ;
55
55
for (auto it = pair.first ; it != pair.second ;) {
@@ -68,7 +68,7 @@ bool TCgiParameters::ErasePattern(const std::string_view name, const std::string
68
68
size_t TCgiParameters::EraseAll (const std::string_view name) {
69
69
size_t num = 0 ;
70
70
71
- const auto pair = equal_range (static_cast <std::string>( name) );
71
+ const auto pair = equal_range (name);
72
72
73
73
for (auto it = pair.first ; it != pair.second ; erase (it++), ++num)
74
74
;
@@ -77,7 +77,7 @@ size_t TCgiParameters::EraseAll(const std::string_view name) {
77
77
}
78
78
79
79
void TCgiParameters::JoinUnescaped (const std::string_view key, char sep, std::string_view val) {
80
- const auto pair = equal_range (static_cast <std::string>( key) );
80
+ const auto pair = equal_range (key);
81
81
auto it = pair.first ;
82
82
83
83
if (it == pair.second ) { // not found
@@ -224,7 +224,7 @@ std::string TCgiParameters::QuotedPrint(const char* safe) const {
224
224
}
225
225
226
226
TCgiParameters::const_iterator TCgiParameters::Find (const std::string_view name, size_t pos) const noexcept {
227
- const auto pair = equal_range (static_cast <std::string>( name) );
227
+ const auto pair = equal_range (name);
228
228
229
229
for (auto it = pair.first ; it != pair.second ; ++it, --pos) {
230
230
if (0 == pos) {
@@ -236,7 +236,7 @@ TCgiParameters::const_iterator TCgiParameters::Find(const std::string_view name,
236
236
}
237
237
238
238
bool TCgiParameters::Has (const std::string_view name, const std::string_view value) const noexcept {
239
- const auto pair = equal_range (static_cast <std::string>( name) );
239
+ const auto pair = equal_range (name);
240
240
241
241
for (auto it = pair.first ; it != pair.second ; ++it) {
242
242
if (value == it->second ) {
@@ -248,27 +248,24 @@ bool TCgiParameters::Has(const std::string_view name, const std::string_view val
248
248
}
249
249
250
250
TQuickCgiParam::TQuickCgiParam (const std::string_view cgiParamStr) {
251
- UnescapeBuf.reserve (CgiUnescapeBufLen (cgiParamStr.size ()));
252
- char * buf = UnescapeBuf.data ();
251
+ const size_t bufLength = CgiUnescapeBufLen (cgiParamStr.size ());
252
+ UnescapeBuf = TTempBuf (bufLength);
253
+ char * buf = UnescapeBuf.Data ();
253
254
254
- auto f = [this , &buf](const std::string_view key, const std::string_view val) {
255
+ auto f = [this , &buf, bufLength ](const std::string_view key, const std::string_view val) {
255
256
std::string_view name = CgiUnescapeBuf (buf, key);
256
257
buf += name.size () + 1 ;
257
258
std::string_view value = CgiUnescapeBuf (buf, val);
258
259
buf += value.size () + 1 ;
259
- Y_ASSERT (buf <= UnescapeBuf.data () + UnescapeBuf. capacity () + 1 /* trailing zero */ );
260
+ Y_ASSERT (buf <= UnescapeBuf.Data () + bufLength );
260
261
emplace (name, value);
261
262
};
262
263
263
264
DoScan<false >(cgiParamStr, f);
264
-
265
- if (buf != UnescapeBuf.data ()) {
266
- UnescapeBuf.resize (buf - UnescapeBuf.data () - 1 /* trailing zero*/ );
267
- }
268
265
}
269
266
270
267
const std::string_view& TQuickCgiParam::Get (const std::string_view name, size_t pos) const noexcept {
271
- const auto pair = equal_range (static_cast <std::string>( name) );
268
+ const auto pair = equal_range (name);
272
269
273
270
for (auto it = pair.first ; it != pair.second ; ++it, --pos) {
274
271
if (0 == pos) {
@@ -280,7 +277,7 @@ const std::string_view& TQuickCgiParam::Get(const std::string_view name, size_t
280
277
}
281
278
282
279
bool TQuickCgiParam::Has (const std::string_view name, const std::string_view value) const noexcept {
283
- const auto pair = equal_range (static_cast <std::string>( name) );
280
+ const auto pair = equal_range (name);
284
281
285
282
for (auto it = pair.first ; it != pair.second ; ++it) {
286
283
if (value == it->second ) {
0 commit comments