Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Pass String by const reference [3.0]#6583

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
d-a-v merged 2 commits intoesp8266:masterfromdirkmueller:string_cleanups_30
Jul 10, 2020

Conversation

@dirkmueller
Copy link
Contributor

Passing String by value means a full copy-constructor/temporary
string creation which is slightly inefficient. Avoid that
by using const references.

Copy link
Collaborator

@earlephilhowerearlephilhower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

These are all basically private inside ESP8266WebServer, so I don't see any issue w/user classes even though they are virtual methods.

@devyte
Copy link
Collaborator

The reason they're virtual is to allow a user to implement his own RequestHandler objects.
Target must be v3.

@devytedevyte added this to the3.0.0 milestoneOct 3, 2019
@earlephilhower
Copy link
Collaborator

Actually,@devyte, while what you say ispossible, IMO they're virtual because we need to store a pointer to a generic RequestHandler in the webserver (i.e. internal considerations, not custom overloads).

Overloaded classes would suffer object slicing if we stored a pointer to the base class in the WebServer object, so these functions need to be virtual (even though I was able to rewrite the WebServer class to be a template w/o virtuals).

Passing String by value means a full copy-constructor/temporarystring creation which is slightly inefficient. Avoid thatby using const references.
boolhandle(WebServerType& server, HTTPMethod requestMethod, String requestUri)override {
boolhandle(WebServerType& server, HTTPMethod requestMethod,const String& __requestUri)override {
StringrequestUri(__requestUri);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This String copy can be handled differently in a further fixing commit.

@d-a-vd-a-v merged commit83158af intoesp8266:masterJul 10, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@d-a-vd-a-vd-a-v approved these changes

@earlephilhowerearlephilhowerearlephilhower approved these changes

@devytedevytedevyte approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

3.0.0

Development

Successfully merging this pull request may close these issues.

4 participants

@dirkmueller@devyte@earlephilhower@d-a-v

[8]ページ先頭

©2009-2025 Movatter.jp