Skip to content

Commit 12b5f49

Browse files
committed
Replace one use of LinkedList<T> with std::vector for web request path params
Fraction of commit 9b98550 of dumbfixes branch of 0xFEEDC0DE64 fork of ESPAsyncWebServer. Split off for clarity.
1 parent 8feb673 commit 12b5f49

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/ESPAsyncWebServer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class AsyncWebServerRequest {
184184

185185
std::list<AsyncWebHeader> _headers;
186186
LinkedList<AsyncWebParameter *> _params;
187-
LinkedList<String *> _pathParams;
187+
std::vector<String> _pathParams;
188188

189189
uint8_t _multiParseState;
190190
uint8_t _boundaryPosition;

src/WebRequest.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ AsyncWebServerRequest::AsyncWebServerRequest(AsyncWebServer* s, AsyncClient* c)
5252
, _contentLength(0)
5353
, _parsedLength(0)
5454
, _params(LinkedList<AsyncWebParameter *>([](AsyncWebParameter *p){ delete p; }))
55-
, _pathParams(LinkedList<String *>([](String *p){ delete p; }))
5655
, _multiParseState(0)
5756
, _boundaryPosition(0)
5857
, _itemStartIndex(0)
@@ -78,7 +77,7 @@ AsyncWebServerRequest::~AsyncWebServerRequest(){
7877
_headers.clear();
7978

8079
_params.free();
81-
_pathParams.free();
80+
_pathParams.clear();
8281

8382
_interestingHeaders.clear();
8483

@@ -254,7 +253,7 @@ void AsyncWebServerRequest::_addParam(AsyncWebParameter *p){
254253
}
255254

256255
void AsyncWebServerRequest::_addPathParam(const char *p){
257-
_pathParams.add(new String(p));
256+
_pathParams.emplace_back(p);
258257
}
259258

260259
void AsyncWebServerRequest::_addGetParams(const String& params){
@@ -915,8 +914,7 @@ const String& AsyncWebServerRequest::argName(size_t i) const {
915914
}
916915

917916
const String& AsyncWebServerRequest::pathArg(size_t i) const {
918-
auto param = _pathParams.nth(i);
919-
return param ? **param : emptyString;
917+
return i < _pathParams.size() ? _pathParams[i] : emptyString;
920918
}
921919

922920
const String& AsyncWebServerRequest::header(const char* name) const {

0 commit comments

Comments
 (0)