summaryrefslogtreecommitdiff
path: root/AK/StringUtils.cpp
AgeCommit message (Collapse)Author
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-04-17AK: Remove String-from-StringView optimizationAndreas Kling
We had an unusual optimization in AK::StringView where constructing a StringView from a String would cause it to remember the internal StringImpl pointer of the String. This was used to make constructing a String from a StringView fast and copy-free. I tried removing this optimization and indeed we started seeing a ton of allocation traffic. However, all of it was due to a silly pattern where functions would take a StringView and then go on to create a String from it. I've gone through most of the code and updated those functions to simply take a String directly instead, which now makes this optimization unnecessary, and indeed a source of bloat instead. So, let's get rid of it and make StringView a little smaller. :^)
2021-04-17AK: Implement case-insensitive StringUtils::matches() without allocsAndreas Kling
Previously this would create new to_lowercase()'d strings from the needle and the haystack. This generated a huge amount of malloc traffic in some programs.
2021-02-26Everywhere: Remove a bunch of redundant 'AK::' namespace prefixesLinus Groh
This is basically just for consistency, it's quite strange to see multiple AK container types next to each other, some with and some without the namespace prefix - we're 'using AK::Foo;' a lot and should leverage that. :^)
2021-02-21AK: Add String{,Utils}::to_snakecase()Linus Groh
This is an improved version of WrapperGenerator's snake_name(), which seems like the kind of thing that could be useful elsewhere but would end up getting duplicated - so let's add this to AK::String instead, like to_{lowercase,uppercase}().
2021-01-12AK: Add String{View,}::find(StringView)AnotherTest
I personally mistook `find_first_of(StringView)` to be analogous to this so let's add a `find()` method that actually searches the string.
2021-01-11AK: Specialise convert_to_uint<T> and to_uint<T> for 'long' variantsAnotherTest
2021-01-03AK: Add String{,View}::is_whitespace()AnotherTest
+Tests!
2020-12-29AK: Allow trailing '*'s in a glob pattern to match nothingAnotherTest
Fixes part of #4607.
2020-12-21AK: Check for overflow in StringUtils::convert_to_intSahan Fernando
2020-12-21AK: Generalize AK::String::to_int() for more typesSahan Fernando
2020-11-17AK: Trim whitespace in StringUtils::convert_to_{int,uint,uint_from_hex}()Linus Groh
Personally I found this unintuitive at first, but it is in line with strtol(), Python's int() or JavaScript's parseInt(), so I guess it makes sense. Fixes #4097.
2020-11-14AK: Fix StringUtils::contains() case insensitive searchLinus Groh
It would incorrectly return false if needle was at the end the string.
2020-10-29AK: Make String::matches() capable of reporting match positions tooAnotherTest
Also, rewrite StringUtils::match(), because the old implementation was fairly broken, e.g. "acdcxb" would *not* match "a*?b".
2020-10-22AK: Enhance String::contains to allow case-insensitive searchesTom
2020-09-27AK: Move trim_whitespace() into StringUtils and add it to StringViewAnotherTest
No behaviour change; also patches use of `String::TrimMode` in LibJS.
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-26AK: Add case insensitive String::ends_with supportBrian Gianforcaro
FileSystemPath::has_extension was jumping through hoops and allocating memory to do a case insensitive comparison needlessly. Extend the existing String::ends_with method to allow the caller to specify the case sensitivity required.
2020-05-26AK: Move String::ends_with implementation to StringUtilsBrian Gianforcaro
Centralizing so it can be used by other string implementations
2020-05-21AK: StringUtils, add "convert_to_uint_from_hex" methodHüseyin ASLITÜRK
New method to convert hex string unsigned integer.
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: Run clang-format on StringUtils.{cpp,h}Andreas Kling
2020-03-02AK: Add missing copyright headers to StringUtils.{cpp,h}Andreas Kling
2020-03-02AK: Move to_int(), to_uint() implementations to StringUtils (#1338)howar6hill
Provide wrappers in String and StringView. Add some tests for the implementations.
2020-03-02AK: Move the wildcard-matching implementation to StringUtilshowar6hill
Provide wrappers in the String and StringView classes, and add some tests.