Luke
a5ecb9bd6b
AK: Add case insensitive version of starts_with
2020-07-21 01:08:32 +02:00
Andreas Kling
fdfda6dec2
AK: Make string-to-number conversion helpers return Optional
...
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-06-12 21:28:55 +02:00
Andreas Kling
643464c455
AK: Make {String,FlyString}::is_one_of() const
...
Also, make the zero-argument variant private since it's not meant to be
called by clients directly.
2020-05-30 11:31:49 +02:00
Brian Gianforcaro
129462cca7
AK: Unify FlyString/StringView::ends_with implementation on StringUtils::ends_with
...
This creates a unified implementation of ends_with with case sensitivity
across String/StringView/FlyString.
2020-05-26 13:17:19 +02:00
Andreas Kling
5e77517e6e
AK: Add String::is_one_of(...)
...
This allows you to compare a string against an arbitrary number of
other strings with a single call.
2020-05-25 19:51:23 +02:00
Andreas Kling
e4b9cf9b6c
AK: Some FlyString improvements
...
We're now clever enough to notice when we're constructing a FlyString
from a String that is actually already a FlyString. :^)
2020-05-05 11:26:03 +02:00
Andreas Kling
888e35f0fe
AK: Add ALWAYS_INLINE, NEVER_INLINE and FLATTEN macros
...
It's tedious to write (and look at) [[gnu::always_inline]] etc. :^)
2020-04-30 11:43:25 +02:00
Andreas Kling
2db2b8b0ef
AK: Add FlyString::is_empty()
2020-04-16 20:22:54 +02:00
Andreas Kling
02e0fab19a
AK: Let FlyString::hash() assume that the string was already hashed
...
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-13 12:27:05 +02:00
Andreas Kling
8cbb8491cb
AK: Add FlyString::hash()
2020-04-10 16:26:59 +02:00
Andreas Kling
95cc4c7e74
AK: Add some string comparison operators
...
Some of these are very inefficient. It's nice to have some optimization
opportunities in the future though. :^)
2020-03-28 09:11:13 +01:00
Andreas Kling
404de10a15
AK: Add FlyString::is_null()
2020-03-24 16:14:10 +01:00
Andreas Kling
7d862dd5fc
AK: Reduce header dependency graph of String.h
...
String.h no longer pulls in StringView.h. We do this by moving a bunch
of String functions out-of-line.
2020-03-23 13:48:44 +01:00
Andreas Kling
c4a6d6ae9f
AK: Add FlyString::to_lowercase() and LogStream operator<<(FlyString)
2020-03-22 19:07:02 +01:00
Andreas Kling
26bc3d4ea0
AK: Add FlyString::equals_ignoring_case(StringView)
...
And share the code with String by moving the logic to StringUtils. :^)
2020-03-22 13:07:45 +01:00
Andreas Kling
4f72f6b886
AK: Add FlyString, a simple flyweight string class
...
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
2020-03-22 13:03:43 +01:00