LibJS: Make Optional<Utf16String> use less space
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

By specializing the template, we can shrink it from 16 to 8 bytes.
This makes PrimitiveString a measly 32 bytes. :^)
This commit is contained in:
Andreas Kling 2025-03-30 00:27:45 +00:00 committed by Andreas Kling
commit 4dc63ddf49
Notes: github-actions[bot] 2025-03-30 06:17:42 +00:00
2 changed files with 106 additions and 1 deletions

View file

@ -84,6 +84,12 @@ Utf16String Utf16String::create(Utf16View const& string)
return Utf16String { Detail::Utf16StringImpl::create(string) };
}
Utf16String Utf16String::invalid()
{
static auto invalid = Utf16String {};
return invalid;
}
Utf16String::Utf16String(NonnullRefPtr<Detail::Utf16StringImpl> string)
: m_string(move(string))
{