-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
AK: Cherry Pick the Optional changes from LB #25337
Draft
Hendiadyoin1
wants to merge
9
commits into
SerenityOS:master
Choose a base branch
from
Hendiadyoin1:LB-Ak-changes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
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
github-actions
bot
added
👀 pr-needs-review
PR needs review from a maintainer or community member
and removed
👀 pr-needs-review
PR needs review from a maintainer or community member
labels
Nov 9, 2024
Ah dammit it depends on some random other commit introducing new String functions, |
This feature is unused in Ladybird and will complicate an upcoming patch to hand-off StringBuilder's memory to String. (cherry picked from commit af220af8bf15f9eb297a165e6d2ae3bf5bbc49fc)
Opening StringData.h in any clangd-enabled editor previously resulted in a sea of clangd errors. (cherry picked from commit 77eef8a8f6723b1e2fb5107aac7cf39bc1b40dad)
Currently, invoking StringBuilder::to_string will re-allocate the string data to construct the String. This is wasteful both in terms of memory and speed. The goal here is to simply hand the string buffer over to String, and let String take ownership of that buffer. To do this, StringBuilder must have the same memory layout as Detail::StringData. This layout is just the members of the StringData class followed by the string itself. So when a StringBuilder is created, we reserve sizeof(StringData) bytes at the front of the buffer. StringData can then construct itself into the buffer with placement new. Things to note: * StringData must now be aware of the actual capacity of its buffer, as that can be larger than the string size. * We must take care not to pass ownership of inlined string buffers, as these live on the stack. (cherry picked from commit 29879a69a4b2eda4f0315027cb1e86964d333221; amended minor conflict in AK/String.h due to us not having String::from_utf16() from LadybirdBrowser/ladybird#674, last commit)
For performance, rather than slowly incrementing the capacity of the rope string's buffer, compute an approximate length for that buffer to be reserved up front. (cherry picked from commit e8f4ae487d228dac491a446ed548400176331ae9)
In contrast to Ladybird, we won't disable assertions in release builds, though.
Using CRTP and `static_cast`s because "deducing this" is still not fully supported yet. (cherry picked from commit a70ed6a2ada94df63e12c94d35166b7d4ca0b90a)
`Optional` and `Variant` both use essentially the same pattern of only declaring a copy constructor/move constructor/destructor and copy/move assignment operator if all of their template parameters have one. Let's move these into a macro to avoid code duplication and to give a name to the thing we are trying to accomplish. (cherry picked from commit fcdf3014f1bfbc9b90560d0399f0dbc33ccca9b6)
Slice the size of `Optional<{,Fly}String>` in half by introducing `UINTPTR_MAX` as an invalid bit pattern for these values. (cherry picked from commit 2457118024a9d3b39178bba0e92c34923b381f20)
This was previously still valid since the `Optional<String>` move constructor copied its input, but since the move is now destructive, the code no longer works. (cherry picked from commit a733e2a31c0c67ee262a1676c5ad8e0d7415dbbb)
Depends on: #25131 |
Hendiadyoin1
force-pushed
the
LB-Ak-changes
branch
from
November 9, 2024 15:54
46c243d
to
b0b2fde
Compare
(That one also depends on other things.) |
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.
This cherry picks LadybirdBrowser/ladybird#2032
With additional changes to accommodate #22870
This also adds a compat commit introducing
ASSERT
as an alias toVERIFY
@nico tell me if this is correct