-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Speed up empty String creation slightly #6573
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
As @DirkMuller found out in esp8266#6568, there is a difference in code executed between `String str(nullptr)` and `String str("")`, but in the end the actual object is identical. It's a few bytes of code, but every little bit counts. Update the default `String()` constructor to use `nullptr` and not `""`. This will remove a constant literal load and the execution of the String::copy method and strlen().
devyte
approved these changes
Sep 30, 2019
6 tasks
earlephilhower
added a commit
that referenced
this pull request
Oct 1, 2019
This reverts commit 1aeea12.
earlephilhower
added a commit
to earlephilhower/Arduino
that referenced
this pull request
Oct 1, 2019
PR esp8266#6573 introduced a corner case where a blind String() without any initialization was in an in invalid state because the buffer and len would not be updated properly. Concatenating to the empty string could cause a failure. Now, set the default state in ::init() to SSO (which is what happened before when we were using String(char *s="")) and fix the crash.
earlephilhower
added a commit
to earlephilhower/Arduino
that referenced
this pull request
Oct 1, 2019
PR esp8266#6573 introduced a corner case where a blind String() without any initialization was in an in invalid state because the buffer and len would not be updated properly. Concatenating to the empty string could cause a failure. Now, set the default state in ::init() to SSO (which is what happened before when we were using String(char *s="")) and fix the crash.
earlephilhower
added a commit
that referenced
this pull request
Oct 1, 2019
* Replace ASM block w/C marco for PSTR GAS doesn't support the C language idiom of catenating two strings together with quotes (i.e. "x" "y" === "xy"). Specify the section attribute fully in the section attribute, instead, to allow this. * Fix WString optimization PR #6573 introduced a corner case where a blind String() without any initialization was in an in invalid state because the buffer and len would not be updated properly. Concatenating to the empty string could cause a failure. Now, set the default state in ::init() to SSO (which is what happened before when we were using String(char *s="")) and fix the crash.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As @dirkmueller (sorry bout typo!) found out in #6568, there is a difference in code
executed between
String str(nullptr)
andString str("")
, but in theend the actual object is identical. It's a few bytes of code, but every
little bit counts.
Update the default
String()
constructor to usenullptr
and not""
.This will remove a constant literal load and the execution of the
String::copy method and strlen().