summaryrefslogtreecommitdiff
path: root/AK/FlyString.h
AgeCommit message (Collapse)Author
2023-04-06AK: Add FlyString::is_one_of for variadic string comparisonKenneth Myhra
2023-03-11AK: Add FlyString::from_deprecated_fly_string()Kenneth Myhra
Let's add FlyString::from_deprecated_fly_string() so we can use it instead of FlyString::from_utf8(). This will make it easier to detect potential unncessary allocations as we transfer to FlyString.
2023-03-08AK: Add FlyString::equals_ignoring_ascii_case()Andreas Kling
This is similar to equals_ignoring_case() but only cares about ASCII case insensitivity.
2023-03-05AK: Add FlyString::to_deprecated_fly_string()Kenneth Myhra
This adds the conversion function to_deprecated_fly_string() to enable conversion from new FlyString to DeprecatedFlyString.
2023-02-25AK: Add operator""_{short_,}string to create a String from a literalLinus Groh
We briefly discussed this when adding the new String type but couldn't settle on a name. However, having to use String::from_utf8() on every literal string is a bit unwieldy, so let's have these options available! Naming-wise '_string' is not as short as 'sv' but should be relatively clear; it also matches '_bigint' and '_ubigint' in length. '_short_string' may be longer than the actual string itself, but it's still an improvement over the static function :^) Since our C++ source files are UTF-8 encoded anyway, it should be impossible to create a string literal with invalid UTF-8, so including that in the name is not as important as in the function that can receive arbitrary data.
2023-02-19AK: Make FlyString(String) constructor implicitSam Atkins
This stops us needing a lot of ugly `FlyString { ... }` wrappers. THis is the behavior that `DeprecatedFlyString(DeprecatedString)` has so it should be fine.
2023-02-15AK: Let FlyStrings be assigned from StringsSam Atkins
2023-01-12AK: Implement FlyString for the new String classTimothy Flynn
This implements a FlyString that will de-duplicate String instances. The FlyString will store the raw encoded data of the String instance: If the String is a short string, FlyString holds the String::ShortString bytes; otherwise FlyString holds a pointer to the Detail::StringData. FlyString itself does not know about String's storage or how to refcount its Detail::StringData. It defers to String to implement these details.
2023-01-09AK+Everywhere: Rename FlyString to DeprecatedFlyStringTimothy Flynn
DeprecatedFlyString relies heavily on DeprecatedString's StringImpl, so let's rename it to A) match the name of DeprecatedString, B) write a new FlyString class that is tied to String.
2023-01-02Everywhere: Fix badly-formatted includesBen Wiederhake
In 7c5e30daaa615ad3a2ef55222423a747ac0a1227, the focus was "only" on Userland/Libraries/, whereas this commit cleans up the remaining headers in the repo, and any new badly-formatted include.
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
2022-11-26AK: Make it possible to not `using` AK classes into the global namespaceAndreas Kling
This patch adds the `USING_AK_GLOBALLY` macro which is enabled by default, but can be overridden by build flags. This is a step towards integrating Jakt and AK types.
2022-11-06Everywhere: Remove redundant inequality comparison operatorsDaniel Bertalan
C++20 can automatically synthesize `operator!=` from `operator==`, so there is no point in writing such functions by hand if all they do is call through to `operator==`. This fixes a compile error with compilers that implement P2468 (Clang 16 currently). This paper restores the C++17 behavior that if both `T::operator==(U)` and `T::operator!=(U)` exist, `U == T` won't be rewritten in reverse to call `T::operator==(U)`. Removing `!=` operators makes the rewriting possible again. See https://reviews.llvm.org/D134529#3853062
2022-10-23AK: Add to_{double, float} convenience functions to all string typesdavidot
These are guarded with #ifndef KERNEL, since doubles (and floats) are not allowed in KERNEL mode. In StringUtils there is convert_to_floating_point which does have a template parameter incase you have a templated type.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-06-18AK: Add a way to disable the trimming of whitespace in to_*intsin-ack
This behavior might not always be desirable, and so this patch adds a way to disable it.
2021-06-13AK: Add FlyString::from_fly_impl()Andreas Kling
This allows you to create a FlyString directly from a known-fly StringImpl instance.
2021-06-06Revert "Revert "AK: Always inline FlyString::view()""Linus Groh
This reverts commit f09216ac42bac9108e7f36ed2938c6f278f497e4. This was supposed to be a local test only, didn't mean to push it. :^)
2021-06-06Revert "AK: Always inline FlyString::view()"Linus Groh
This reverts commit 66f15c2e0c34caed8ce56075a366b20c4d1819af.
2021-06-05AK: Always inline FlyString::view()Andreas Kling
2021-06-04AK: Inline *String::is_one_of<Ts...>()Ali Mohammad Pur
Previously this was generating a crazy number of symbols, and it was also pretty-damn-slow as it was defined recursively, which made the compiler incapable of inlining it (due to the many many layers of recursion before it terminated). This commit replaces the recursion with a pack expansion and marks it always-inline.
2021-06-03AK: Allow inlining more string functionsGunnar Beutner
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-01-12AK: Simplify constructors and conversions from nullptr_tLenny Maiorani
Problem: - Many constructors are defined as `{}` rather than using the ` = default` compiler-provided constructor. - Some types provide an implicit conversion operator from `nullptr_t` instead of requiring the caller to default construct. This violates the C++ Core Guidelines suggestion to declare single-argument constructors explicit (https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c46-by-default-declare-single-argument-constructors-explicit). Solution: - Change default constructors to use the compiler-provided default constructor. - Remove implicit conversion operators from `nullptr_t` and change usage to enforce type consistency without conversion.
2020-12-21AK: Generalize AK::String::to_int() for more typesSahan Fernando
2020-07-28AK: Tweak String::is_one_of() and FlyString::is_one_of()Andreas Kling
Switch the comparisons from "other == *this" to "*this == other".
2020-07-21AK: Add case insensitive version of starts_withLuke
2020-06-12AK: Make string-to-number conversion helpers return OptionalAndreas Kling
Get rid of the weird old signature: - int StringType::to_int(bool& ok) const And replace it with sensible new signature: - Optional<int> StringType::to_int() const
2020-05-30AK: Make {String,FlyString}::is_one_of() constAndreas Kling
Also, make the zero-argument variant private since it's not meant to be called by clients directly.
2020-05-26AK: Unify FlyString/StringView::ends_with implementation on ↵Brian Gianforcaro
StringUtils::ends_with This creates a unified implementation of ends_with with case sensitivity across String/StringView/FlyString.
2020-05-25AK: Add String::is_one_of(...)Andreas Kling
This allows you to compare a string against an arbitrary number of other strings with a single call.
2020-05-05AK: Some FlyString improvementsAndreas Kling
We're now clever enough to notice when we're constructing a FlyString from a String that is actually already a FlyString. :^)
2020-04-30AK: Add ALWAYS_INLINE, NEVER_INLINE and FLATTEN macrosAndreas Kling
It's tedious to write (and look at) [[gnu::always_inline]] etc. :^)
2020-04-16AK: Add FlyString::is_empty()Andreas Kling
2020-04-13AK: Let FlyString::hash() assume that the string was already hashedAndreas Kling
Since the FlyString deduplication mechanism uses a HashTable, we know that any StringImpl inside a non-null FlyString will already have its lazily computed hash.
2020-04-10AK: Add FlyString::hash()Andreas Kling
2020-03-28AK: Add some string comparison operatorsAndreas Kling
Some of these are very inefficient. It's nice to have some optimization opportunities in the future though. :^)
2020-03-24AK: Add FlyString::is_null()Andreas Kling
2020-03-23AK: Reduce header dependency graph of String.hAndreas Kling
String.h no longer pulls in StringView.h. We do this by moving a bunch of String functions out-of-line.
2020-03-22AK: Add FlyString::to_lowercase() and LogStream operator<<(FlyString)Andreas Kling
2020-03-22AK: Add FlyString::equals_ignoring_case(StringView)Andreas Kling
And share the code with String by moving the logic to StringUtils. :^)
2020-03-22AK: Add FlyString, a simple flyweight string classAndreas Kling
FlyString is a flyweight string class that wraps a RefPtr<StringImpl> known to be unique among the set of FlyStrings. The class is very unoptimized at the moment. When to use FlyString: - When you want O(1) string comparison - When you want to deduplicate a lot of identical strings When not to use FlyString: - For strings that don't need either of the above features - For strings that are likely to be unique