-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce copy of Strings in WebServer RequestHandler #10345
Reduce copy of Strings in WebServer RequestHandler #10345
Conversation
👋 Hello TD-er, we appreciate your contribution to this project! Click to see more instructions ...
Review and merge process you can expect ...
|
Memory usage test (comparing PR against master branch)The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.
Click to expand the detailed deltas report [usage change in BYTES]
|
Test Results 56 files - 83 56 suites - 83 4m 58s ⏱️ - 1h 36m 58s Results for commit 6815a0d. ± Comparison against base commit 9e60bbe. This pull request removes 9 tests.
♻️ This comment has been updated with latest results. |
|
||
if (!_isFile) { | ||
// Base URI doesn't point to a file. | ||
// If a directory is requested, look for index file. | ||
if (requestUri.endsWith("/")) { | ||
requestUri += "index.htm"; | ||
return handle(server, requestMethod, String(requestUri + "index.htm")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we can keep the requestUri
const
if (!canHandle(server, requestMethod, requestUri)) { | ||
return false; | ||
} | ||
|
||
log_v("StaticRequestHandler::handle: request=%s _uri=%s\r\n", requestUri.c_str(), _uri.c_str()); | ||
|
||
String path(_path); | ||
String eTagCode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moving it changes nothing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Less allocated on the stack when it returns early (e.g. due to the added single recursive call you asked about in the previous comment.
Description of Change
Nearly each function of WebServer RequestHandler does copy the String arguments instead of using
const String&
.N.B. This might break some classes which inherit from
RequestHandler