Skip to content
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
wants to merge 9 commits into
base: master
Choose a base branch
from

Commits on Nov 9, 2024

  1. AK: Remove StringBuilder's UseInlineCapacityOnly feature

    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)
    trflynn89 authored and Hendiadyoin1 committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    25a4238 View commit details
    Browse the repository at this point in the history
  2. AK: Add missing includes to StringData.h

    Opening StringData.h in any clangd-enabled editor previously resulted in
    a sea of clangd errors.
    
    (cherry picked from commit 77eef8a8f6723b1e2fb5107aac7cf39bc1b40dad)
    trflynn89 authored and Hendiadyoin1 committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    c39b1ba View commit details
    Browse the repository at this point in the history
  3. AK: Construct Strings from StringBuilder without re-allocating the data

    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)
    trflynn89 authored and Hendiadyoin1 committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    4a91f21 View commit details
    Browse the repository at this point in the history
  4. LibJS: Pre-allocate the resolved rope string's underlying buffer

    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)
    trflynn89 authored and Hendiadyoin1 committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    92b580d View commit details
    Browse the repository at this point in the history
  5. AK: Add a ASSERT() wrapper for Ladybird upstream compatibility

    In contrast to Ladybird, we won't disable assertions in release builds,
    though.
    Hendiadyoin1 committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    a2fcf55 View commit details
    Browse the repository at this point in the history
  6. AK: Add OptionalBase class to reduce code duplication

    Using CRTP and `static_cast`s because "deducing this" is
    still not fully supported yet.
    
    (cherry picked from commit a70ed6a2ada94df63e12c94d35166b7d4ca0b90a)
    yyny authored and Hendiadyoin1 committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    80dc181 View commit details
    Browse the repository at this point in the history
  7. AK: Move "conditional xtor" pattern into a macro

    `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)
    yyny authored and Hendiadyoin1 committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    849acbf View commit details
    Browse the repository at this point in the history
  8. AK: Add template specializations for Optional<{,Fly}String>

    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)
    yyny authored and Hendiadyoin1 committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    ce5882d View commit details
    Browse the repository at this point in the history
  9. LibWeb: Fix use-after-move in URLSearchParams::update

    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)
    yyny authored and Hendiadyoin1 committed Nov 9, 2024
    Configuration menu
    Copy the full SHA
    b0b2fde View commit details
    Browse the repository at this point in the history