-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Everywhere: Remove AK::StringView(char const*) :^) #14555
Everywhere: Remove AK::StringView(char const*) :^) #14555
Commits on Jul 12, 2022
-
AK: Make CheckedFormatString pass the char array size to StringView
This makes the assumption that we never pass a stack-allocated char array to CheckedFormatString arguments (dbgln, outln, warnln). This assumption seems to hold true for the current state of Serenity code, at least. :^)
Configuration menu - View commit details
-
Copy full SHA for a4eee80 - Browse repository at this point
Copy the full SHA a4eee80View commit details -
AK: Explicitly calculate length of char* when printing
This moves out the calculation of the char* out to the formatter. Additionally, we now print (null) when a null pointer is passed.
Configuration menu - View commit details
-
Copy full SHA for 4d5a719 - Browse repository at this point
Copy the full SHA 4d5a719View commit details -
AK: Add string literal helpers to AK::SourceGenerator
Since all uses of SourceGenerator are with literal strings, there is no need to burden generators with the sv suffix.
Configuration menu - View commit details
-
Copy full SHA for 79a7c63 - Browse repository at this point
Copy the full SHA 79a7c63View commit details -
Meta+Userland: Simplify some formatters
These are mostly minor mistakes I've encountered while working on the removal of StringView(char const*). The usage of builder.put_string over Format<FormatString>::format is preferrable as it will avoid the indirection altogether when there's no formatting to be done. Similarly, there is no need to do format(builder, "{}", number) when builder.put_u64(number) works equally well. Additionally a few Strings where only constant strings were used are replaced with StringViews.
Configuration menu - View commit details
-
Copy full SHA for 0184889 - Browse repository at this point
Copy the full SHA 0184889View commit details -
LibChess: Add convenience constructor for Chess::Square
It didn't feel right to add sv suffixes to 2-character strings, so I added this convenience constructor.
Configuration menu - View commit details
-
Copy full SHA for 7f4f24e - Browse repository at this point
Copy the full SHA 7f4f24eView commit details -
LibJS: Emit StringViews for ErrorType instances
This removes the need for calculating each string's length during ErrorType use at the cost of storing it within the binary.
Configuration menu - View commit details
-
Copy full SHA for 2b04aa1 - Browse repository at this point
Copy the full SHA 2b04aa1View commit details -
Configuration menu - View commit details
-
Copy full SHA for fa829f4 - Browse repository at this point
Copy the full SHA fa829f4View commit details -
Tests: Convert TestBase64 decode test to use StringViews directly
Previously it would rely on the implicit StringView conversions. Now the decode_equal function will directly use StringViews.
Configuration menu - View commit details
-
Copy full SHA for ad11148 - Browse repository at this point
Copy the full SHA ad11148View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5280a74 - Browse repository at this point
Copy the full SHA 5280a74View commit details -
Userland: Convert command line arguments to String/StringView
StringView was used where possible. Some utilities still use libc functions which expect null-terminated strings, so String objects were used there instead.
Configuration menu - View commit details
-
Copy full SHA for 6b3d3e6 - Browse repository at this point
Copy the full SHA 6b3d3e6View commit details -
Userland: Remove erroneous String -> char* -> StringView conversions
These were accidental (or leftover) uses of String::characters() to construct StringViews through its StringView(char const*) constructor. Since this constructor is due to be removed, this will no longer work. Plus this prevents strlen from being run on these strings unnecessarily.
Configuration menu - View commit details
-
Copy full SHA for 800d27e - Browse repository at this point
Copy the full SHA 800d27eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4b56df6 - Browse repository at this point
Copy the full SHA 4b56df6View commit details -
LibCore: Add convenience templates for System::{unveil,pledge}
These convenience templates allow the following to be written as before: TRY(Core::System::pledge("promises...")); TRY(Core::System::pledge("promises...", "execpromises...")); TRY(Core::System::unveil("path", "permissions")); TRY(Core::System::unveil(nullptr, nullptr)); Other uses must now append sv to any literal string passed to pledge and unveil.
Configuration menu - View commit details
-
Copy full SHA for 2fd97ab - Browse repository at this point
Copy the full SHA 2fd97abView commit details -
Configuration menu - View commit details
-
Copy full SHA for d80a19d - Browse repository at this point
Copy the full SHA d80a19dView commit details -
Everywhere: Explicitly specify the size in StringView constructors
This commit moves the length calculations out to be directly on the StringView users. This is an important step towards the goal of removing StringView(char const*), as it moves the responsibility of calculating the size of the string to the user of the StringView (which will prevent naive uses causing OOB access).
Configuration menu - View commit details
-
Copy full SHA for 178b053 - Browse repository at this point
Copy the full SHA 178b053View commit details -
Everywhere: Split Error::from_string_literal and Error::from_string_view
Error::from_string_literal now takes direct char const*s, while Error::from_string_view does what Error::from_string_literal used to do: taking StringViews. This change will remove the need to insert `sv` after error strings when returning string literal errors once StringView(char const*) is removed. No functional changes.
Configuration menu - View commit details
-
Copy full SHA for 9186d21 - Browse repository at this point
Copy the full SHA 9186d21View commit details -
Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
Configuration menu - View commit details
-
Copy full SHA for 7a9bbfc - Browse repository at this point
Copy the full SHA 7a9bbfcView commit details -
Everywhere: Replace single-char StringView op. arguments with chars
This prevents us from needing a sv suffix, and potentially reduces the need to run generic code for a single character (as contains, starts_with, ends_with etc. for a char will be just a length and equality check). No functional changes.
Configuration menu - View commit details
-
Copy full SHA for 326099c - Browse repository at this point
Copy the full SHA 326099cView commit details -
Everywhere: Use default StringView constructor over nullptr
While null StringViews are just as bad, these prevent the removal of StringView(char const*) as that constructor accepts a nullptr. No functional changes.
Configuration menu - View commit details
-
Copy full SHA for e67ba36 - Browse repository at this point
Copy the full SHA e67ba36View commit details -
LibCore: Add FIXME note about converting Core::Account to use StringView
This prevents a bunch of utilities from using StringView for their arguments.
Configuration menu - View commit details
-
Copy full SHA for 98474cb - Browse repository at this point
Copy the full SHA 98474cbView commit details -
LibRegex: Remove RegexStringView(char const*) constructor
This allowed passing in a nullptr for the StringView which will not be possible once StringView(char const*) is removed.
Configuration menu - View commit details
-
Copy full SHA for 87d8d26 - Browse repository at this point
Copy the full SHA 87d8d26View commit details -
AK: Remove String <-> char const* comparison operators
During the removal of StringView(char const*), all users of these functions were removed, and they are of dubious value (relying on implicit StringView conversion).
Configuration menu - View commit details
-
Copy full SHA for c306fee - Browse repository at this point
Copy the full SHA c306feeView commit details -
AK+Userland+Tests: Remove URL(char const*) constructor
The StringView(char const*) constructor is being removed, and there was only a few users of this left, which are also cleaned up in this commit.
Configuration menu - View commit details
-
Copy full SHA for cb75f32 - Browse repository at this point
Copy the full SHA cb75f32View commit details -
Tests: Remove StringView char const* initialization test
We now explicitly disallow this.
Configuration menu - View commit details
-
Copy full SHA for 9b21264 - Browse repository at this point
Copy the full SHA 9b21264View commit details -
AK: Remove StringView(char const*) :^)
This constructor relied on running strlen implicitly on its argument, thereby potentially causing out-of-bound reads (some of which were caught a few days ago). The removal of this constructor ensures that the caller must explicitly pass the size of the string by either: 1) Using operator""sv on literal strings; or 2) Calling strlen explicitly, making it clear that the size of the view is being calculated at runtime.
Configuration menu - View commit details
-
Copy full SHA for 54094f6 - Browse repository at this point
Copy the full SHA 54094f6View commit details