ladybird/AK
Timothy Flynn 29879a69a4 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.
2024-07-20 06:45:49 +02:00
..
.clang-tidy Meta: Add basic clang-tidy configuration 2021-11-14 22:52:35 +01:00
AllOf.h AK: Make it possible to not using AK classes into the global namespace 2022-11-26 15:51:34 +01:00
AnyOf.h AK: Make it possible to not using AK classes into the global namespace 2022-11-26 15:51:34 +01:00
Array.h AK: Add to_array() 2024-02-11 18:53:00 +01:00
Assertions.cpp AK: Add ASSERT() and ASSERT_NOT_REACHED() for debug-only assertions 2024-07-10 07:03:20 +02:00
Assertions.h Everywhere: Warn on function definitions without prototypes 2024-07-17 21:51:29 +02:00
Atomic.h AK: Add workaround for faulty Sanitizer warning on gcc 13+ in Atomic 2024-04-23 15:37:07 -06:00
AtomicRefCounted.h Everywhere: Remove unused includes of AK/StdLibExtras.h 2023-01-02 20:27:20 -05:00
Backtrace.h.in AK+CMake: Use the find module to find the correct backtrace(3) header 2024-07-01 10:15:24 -06:00
Badge.h AK: Make it possible to not using AK classes into the global namespace 2022-11-26 15:51:34 +01:00
Base64.cpp AK+LibWeb: Replace our home-grown base64 encoder/decoders with simdutf 2024-07-16 10:27:39 +02:00
Base64.h AK+LibWeb: Replace our home-grown base64 encoder/decoders with simdutf 2024-07-16 10:27:39 +02:00
BigIntBase.h AK: Move generalized internals of UFixedBigIntDivision to BigIntBase 2024-03-25 14:26:29 -06:00
BinaryHeap.h AK: Introduce IntrusiveBinaryHeap and reimplement BinaryHeap using it 2024-02-25 17:24:36 -07:00
BinarySearch.h AK: Make it possible to not using AK classes into the global namespace 2022-11-26 15:51:34 +01:00
BitCast.h AK: Use bit_cast in SIMDExtras.h/AK::Detail::byte_reverse_impl 2024-07-17 09:56:13 -06:00
Bitmap.h AK: Replace C-style casts 2023-03-09 21:43:54 +01:00
BitmapView.h AK: Fix one-off error in BitmapView::find_first and find_one_anywhere 2023-10-11 15:58:16 +02:00
BitStream.h AK: Add BigEndianInputBitStream::bits_until_next_byte_boundary() 2024-02-12 14:08:56 +01:00
BufferedStream.h AK: Don't move trivially copyable types in BufferedStream methods 2024-04-30 13:22:56 +02:00
BuiltinWrappers.h AK: Fix doc comment for bit_scan_forward 2023-10-11 14:36:48 -04:00
BumpAllocator.h AK: Replace C-style casts 2023-03-09 21:43:54 +01:00
ByteBuffer.h AK: Construct Strings from StringBuilder without re-allocating the data 2024-07-20 06:45:49 +02:00
ByteReader.h AK: Make it possible to not using AK classes into the global namespace 2022-11-26 15:51:34 +01:00
ByteString.cpp AK: Disallow calling ByteString methods that return a view on rvalues 2024-04-04 11:23:21 +02:00
ByteString.h AK: Disallow calling ByteString methods that return a view on rvalues 2024-04-04 11:23:21 +02:00
CharacterTypes.h AK: Add is_ascii_uppercase_hex_digit() 2024-03-01 14:17:42 +01:00
Checked.h LibJS+AK: Fix integer overflow UB on (any Int32 - -2147483648) 2024-05-18 18:11:50 +02:00
CheckedFormatString.h AK: Enable format string checking in Clang builds 2024-05-29 13:34:15 -06:00
CircularBuffer.cpp AK: Use hashing to accelerate searching a CircularBuffer 2023-07-06 15:06:20 +01:00
CircularBuffer.h AK: Use hashing to accelerate searching a CircularBuffer 2023-07-06 15:06:20 +01:00
CircularQueue.h Everywhere: Use east const in more places 2024-04-19 06:31:19 -04:00
CMakeLists.txt AK: Remove Lagom tools workaround for simdutf 2024-07-18 14:46:25 +02:00
Concepts.h AK: Add a CallableAs<R, Args...> concept 2023-07-08 23:13:00 +01:00
ConstrainedStream.cpp AK: Move ConstrainedStream from LibWasm and limit discarding 2023-03-21 10:25:13 +01:00
ConstrainedStream.h AK: Add remaining method to ConstrainedStream 2024-07-09 14:22:31 +02:00
CountingStream.cpp AK: Add a Stream wrapper that counts read bytes 2023-03-21 10:25:13 +01:00
CountingStream.h AK: Add a Stream wrapper that counts read bytes 2023-03-21 10:25:13 +01:00
COWVector.h AK+LibRegex+LibWasm: Remove the non-const COWVector::operator[] 2024-03-12 17:10:47 +01:00
DateConstants.h AK: Make it possible to not using AK classes into the global namespace 2022-11-26 15:51:34 +01:00
Debug.h.in LibWebView+LibCore: Manage process lifecycle using a SIGCHLD handler 2024-07-01 18:10:56 +02:00
DefaultDelete.h AK+Everywhere: Move custom deleter capability to OwnPtr 2022-12-17 16:00:08 -05:00
Demangle.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
DeprecatedFlyString.cpp AK+LibJS: Remove null state from DeprecatedFlyString :^) 2024-02-24 15:06:52 -07:00
DeprecatedFlyString.h AK+LibJS: Remove null state from DeprecatedFlyString :^) 2024-02-24 15:06:52 -07:00
Diagnostics.h AK: Add a helper macro to temporarily ignore diagnostics with _Pragma() 2022-12-06 21:31:00 +00:00
DisjointChunks.h AK: Rename GenericTraits to DefaultTraits 2023-11-09 10:05:51 -05:00
DistinctNumeric.h AK: Rename GenericTraits to DefaultTraits 2023-11-09 10:05:51 -05:00
DOSPackedTime.cpp Kernel: Use UnixDateTime wherever applicable 2023-05-24 23:18:07 +02:00
DOSPackedTime.h Kernel: Use UnixDateTime wherever applicable 2023-05-24 23:18:07 +02:00
DoublyLinkedList.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
Endian.h AK: Support non-native endianness in Utf16View 2024-07-18 19:43:57 +02:00
EnumBits.h Everywhere: Remove unused includes of AK/StdLibExtras.h 2023-01-02 20:27:20 -05:00
Enumerate.h AK: Introduce AK::enumerate 2024-03-23 09:02:58 -04:00
Error.cpp Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
Error.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
Find.h AK: Add missing using statements to Find.h 2024-05-06 17:32:19 +02:00
FixedArray.h AK: Don't put element count next to heap-allocated data in FixedArray 2024-05-18 18:30:42 +02:00
FixedPoint.h AK: Stop exporting AK::FixedPoint into the global namespace 2024-07-18 09:43:38 +01:00
FloatingPoint.h AK: Implement floating-point conversions for big-endian 2024-07-05 09:47:08 -06:00
FloatingPointStringConversions.cpp AK: Implement floating-point conversions for big-endian 2024-07-05 09:47:08 -06:00
FloatingPointStringConversions.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
FlyString.cpp AK: Make FlyString::from_utf8*() avoid allocation if possible 2024-03-24 13:28:24 +01:00
FlyString.h AK: Simplify and optimize ASCIICaseInsensitiveFlyStringTraits::equals 2024-04-06 09:17:51 -04:00
Format.cpp AK: Fix {:c} formatter for big-endian 2024-07-05 09:48:15 -06:00
Format.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
Forward.h AK: Construct Strings from StringBuilder without re-allocating the data 2024-07-20 06:45:49 +02:00
Function.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
GenericLexer.cpp Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
GenericLexer.h AK: Make a couple of GenericLexer helper methods protected 2024-07-04 14:16:16 +02:00
GenericShorthands.h AK: Mark generic shorthand functions as constexpr 2023-06-01 06:25:00 +02:00
HashFunctions.h AK: Remove unused rehash_for_collision 2023-02-17 22:29:51 -07:00
HashMap.h Everywhere: Remove usages of template keyword with no parameter list 2024-06-16 07:19:56 -04:00
HashTable.h Everywhere: Use east const in more places 2024-04-19 06:31:19 -04:00
Hex.cpp Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
Hex.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
IDAllocator.h AK: Allow specifying a minimum value for IDs returned by IDAllocator 2023-04-07 16:02:22 +02:00
InsertionSort.h AK: Introduce cutoff to insertion sort for Quicksort 2022-12-12 15:03:57 +00:00
IntegralMath.h AK: Fix off by one error in integral ceil_log2() 2024-05-21 09:31:17 +02:00
IntrusiveDetails.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
IntrusiveList.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
IntrusiveListRelaxedConst.h AK: Make it possible to not using AK classes into the global namespace 2022-11-26 15:51:34 +01:00
IntrusiveRedBlackTree.h Everywhere: Remove unnecessary AK and Detail namespace scoping 2022-12-09 11:25:30 +00:00
IPv4Address.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
IPv6Address.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
IterationDecision.h AK: Make it possible to not using AK classes into the global namespace 2022-11-26 15:51:34 +01:00
Iterator.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
JsonArray.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
JsonArraySerializer.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
JsonObject.cpp Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
JsonObject.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
JsonObjectSerializer.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
JsonParser.cpp AK: Decode paired UTF-16 surrogates in a JSON string 2024-07-04 14:16:16 +02:00
JsonParser.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
JsonValue.cpp AK: Store JsonValue's value in AK::Variant 2024-02-08 08:04:05 -07:00
JsonValue.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
kmalloc.cpp Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
kmalloc.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
LEB128.h AK: Read signed LEB128 integers without 64-bit assumptions 2024-06-18 16:58:33 +02:00
LexicalPath.cpp Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
LexicalPath.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
Math.h AK: Implement floating-point conversions for big-endian 2024-07-05 09:47:08 -06:00
MaybeOwned.h AK: Allow creating a MaybeOwned<Superclass> from a MaybeOwned<Subclass> 2024-03-25 20:35:00 +01:00
MemMem.h Everywhere: Use ReadonlySpan<T> instead of Span<T const> 2023-02-08 19:15:45 +00:00
Memory.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
MemoryStream.cpp AK: Use an enum to specify the open mode instead of a bool 2023-11-08 18:19:34 +01:00
MemoryStream.h AK: Use an enum to specify the open mode instead of a bool 2023-11-08 18:19:34 +01:00
NeverDestroyed.h Everywhere: Run clang-format 2022-12-03 23:52:23 +00:00
NoAllocationGuard.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
Noncopyable.h AK: Add AK_MAKE_DEFAULT_COPYABLE 2024-01-21 16:16:15 -07:00
NonnullOwnPtr.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
NonnullRefPtr.h AK+Kernel+LibVideo: Include workarounds for missing P0960 only in Xcode 2024-05-21 14:24:59 +02:00
NumberFormat.cpp AK+Userland: Return String from human_readable_size() functions 2024-01-25 09:07:32 +01:00
NumberFormat.h AK+Userland: Return String from human_readable_size() functions 2024-01-25 09:07:32 +01:00
NumericLimits.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
Optional.h AK: Remove AK_HAS_CONDITIONALLY_TRIVIAL 2024-05-10 15:03:24 +00:00
OptionParser.cpp AK: Update OptionParser::m_arg_index by substracting skipped args 2024-02-06 00:08:30 +01:00
OptionParser.h Userland+AK: Stop using getopt() for ArgsParser 2023-02-28 15:52:24 +03:30
OwnPtr.h AK: Add a formatter for OwnPtr<T> 2024-06-26 05:47:16 +02:00
Platform.h AK: Add AK_IS_ARCH defines for PowerPC CPU architecture 2024-07-05 09:50:13 -06:00
Queue.h AK: Add fallible dequeue method to Queue 2024-04-19 16:38:55 -04:00
QuickSelect.h AK: Add thresholds to quickselect_inline and Statistics::Median 2023-02-03 19:04:15 +01:00
QuickSort.h AK: Change quicksort comments to standard // style 2022-12-12 15:03:57 +00:00
Random.cpp Everywhere: Use east const in more places 2024-04-19 06:31:19 -04:00
Random.h LibTest: Add more numeric generators 2024-01-12 16:42:51 -07:00
RecursionDecision.h AK: Add missing include in RecursionDecision.h 2023-08-18 08:58:51 +03:30
RedBlackTree.h Everywhere: Use east const in more places 2024-04-19 06:31:19 -04:00
RefCounted.h Everywhere: Remove unused includes of AK/StdLibExtras.h 2023-01-02 20:27:20 -05:00
RefPtr.h AK: Rename GenericTraits to DefaultTraits 2023-11-09 10:05:51 -05:00
Result.h AK: Make it possible to not using AK classes into the global namespace 2022-11-26 15:51:34 +01:00
ReverseIterator.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
ScopedValueRollback.h Everywhere: Run clang-format 2022-12-03 23:52:23 +00:00
ScopeGuard.h AK: Make it possible to not using AK classes into the global namespace 2022-11-26 15:51:34 +01:00
ScopeLogger.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
SegmentedVector.h AK+LibWeb: Use segmented vector to store commands in RecordingPainter 2023-12-30 23:02:46 +01:00
SIMD.h AK: Add introspection helpers to SIMD.h 2024-07-17 09:56:13 -06:00
SIMDExtras.h AK: Use bit_cast in SIMDExtras.h/AK::Detail::byte_reverse_impl 2024-07-17 09:56:13 -06:00
SIMDMath.h AK: Remove the SIMD version of rsqrt() too, for good measure 2024-01-30 10:02:33 +01:00
Singleton.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
SinglyLinkedList.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
SinglyLinkedListSizePolicy.h AK: Combine SinglyLinkedList and SinglyLinkedListWithCount 2023-01-02 20:13:24 +00:00
SipHash.cpp Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
SipHash.h AK: Implement SipHash as the default hash algorithm for most use cases 2023-10-01 11:06:36 +03:30
SourceGenerator.h AK: Allow escaping of keys in SourceGenerator 2024-07-09 11:21:07 +02:00
SourceLocation.h AK: Add copy assignment operator for SourceLocation 2023-09-24 14:55:32 +02:00
Span.h AK: Generalize Span::contains_slow to use the Traits infrastructure 2024-03-16 08:42:33 +01:00
Stack.h Everywhere: Run clang-format 2022-12-03 23:52:23 +00:00
StackInfo.cpp AK: Add stack size fixup for musl libc 2024-05-14 13:56:45 -06:00
StackInfo.h AK: Use __builtin_frame_address to find current stack depth remaining 2023-07-01 07:03:11 +02:00
Statistics.h AK: Export Statistics to the global namespace 2024-05-18 18:30:07 +02:00
StdLibExtraDetails.h Everywhere: Run clang-format 2024-04-24 16:50:01 -04:00
StdLibExtras.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
Stream.cpp AK: Rename Stream::format() to Stream::write_formatted() 2023-04-25 07:30:16 +01:00
Stream.h AK: Add a Stream::write_until_depleted overload for string types 2024-04-04 11:23:21 +02:00
String.cpp AK: Construct Strings from StringBuilder without re-allocating the data 2024-07-20 06:45:49 +02:00
String.h AK: Construct Strings from StringBuilder without re-allocating the data 2024-07-20 06:45:49 +02:00
StringBase.cpp AK: Construct Strings from StringBuilder without re-allocating the data 2024-07-20 06:45:49 +02:00
StringBase.h AK: Construct Strings from StringBuilder without re-allocating the data 2024-07-20 06:45:49 +02:00
StringBuilder.cpp AK: Construct Strings from StringBuilder without re-allocating the data 2024-07-20 06:45:49 +02:00
StringBuilder.h AK: Construct Strings from StringBuilder without re-allocating the data 2024-07-20 06:45:49 +02:00
StringData.h AK: Construct Strings from StringBuilder without re-allocating the data 2024-07-20 06:45:49 +02:00
StringFloatingPointConversions.cpp AK+LibCrypto: Delete 64x64 wide multiplication workarounds 2023-03-04 22:10:03 -07:00
StringFloatingPointConversions.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
StringHash.h AK: Implement SipHash as the default hash algorithm for most use cases 2023-10-01 11:06:36 +03:30
StringImpl.cpp AK+Everywhere: Remove the null state of DeprecatedString 2023-10-13 18:33:21 +03:30
StringImpl.h AK: Make Deprecated{Fly,}String and StringImpl const-correct 2023-02-21 00:54:04 +01:00
StringUtils.cpp Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
StringUtils.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
StringView.cpp Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
StringView.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
TemporaryChange.h AK: Make it possible to not using AK classes into the global namespace 2022-11-26 15:51:34 +01:00
Time.cpp Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
Time.h AK: Stop exporting AK::Duration into the global namespace 2024-07-18 09:43:38 +01:00
Traits.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
Trie.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
Try.h AK+Everywhere: Do not implicitly copy variables in TRY macros 2023-02-10 09:08:52 +00:00
Tuple.h AK: Make IndexSequence use size_t 2024-02-11 18:53:00 +01:00
TypeCasts.h Everywhere: Remove unused includes of AK/StdLibExtras.h 2023-01-02 20:27:20 -05:00
TypedTransfer.h Everywhere: Stop shoving things into ::std and mentioning them as such 2022-12-14 11:44:32 +01:00
TypeList.h AK: Make IndexSequence use size_t 2024-02-11 18:53:00 +01:00
Types.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
UFixedBigInt.h Everywhere: Use east const in more places 2024-04-19 06:31:19 -04:00
UFixedBigIntDivision.h AK: Move generalized internals of UFixedBigIntDivision to BigIntBase 2024-03-25 14:26:29 -06:00
UnicodeUtils.h AK: Stop using ShortString in String::from_code_point 2024-01-21 16:16:15 -07:00
Utf8View.cpp AK: Replace UTF-8 validation and length computation with simdutf 2024-07-18 14:46:25 +02:00
Utf8View.h AK: Replace UTF-8 validation and length computation with simdutf 2024-07-18 14:46:25 +02:00
Utf16View.cpp AK: Support non-native endianness in Utf16View 2024-07-18 19:43:57 +02:00
Utf16View.h AK: Support non-native endianness in Utf16View 2024-07-18 19:43:57 +02:00
Utf32View.cpp AK: Prepare Utf32View for use within templated LibGfx contexts 2023-02-22 10:14:36 +01:00
Utf32View.h AK: Add a Utf32View::substring_view overload to take only an offset 2023-03-08 18:57:53 +00:00
Variant.h Everywhere: Remove usages of template keyword with no parameter list 2024-06-16 07:19:56 -04:00
Vector.h Everywhere: Remove all KERNEL #defines 2024-06-18 09:36:25 +02:00
Weakable.h AK+LibJS: Remove OFFSET_OF and its users 2024-02-29 09:00:00 +01:00
WeakPtr.h AK: Make WeakPtr<T>::value() return NonnullRefPtr<T> 2023-02-05 15:38:19 +01:00