mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:38:12 +00:00
StringView: Rename characters() to characters_without_null_termination().
This should make you think twice before trying to use the const char* from a StringView as if it's a null-terminated string.
This commit is contained in:
parent
567551bc12
commit
0e75aba7c3
21 changed files with 57 additions and 46 deletions
|
@ -198,7 +198,7 @@ bool String::starts_with(const StringView& str) const
|
|||
return false;
|
||||
if (str.length() > length())
|
||||
return false;
|
||||
return !memcmp(characters(), str.characters(), str.length());
|
||||
return !memcmp(characters(), str.characters_without_null_termination(), str.length());
|
||||
}
|
||||
|
||||
bool String::ends_with(const StringView& str) const
|
||||
|
@ -209,7 +209,7 @@ bool String::ends_with(const StringView& str) const
|
|||
return false;
|
||||
if (str.length() > length())
|
||||
return false;
|
||||
return !memcmp(characters() + (length() - str.length()), str.characters(), str.length());
|
||||
return !memcmp(characters() + (length() - str.length()), str.characters_without_null_termination(), str.length());
|
||||
}
|
||||
|
||||
String String::repeated(char ch, int count)
|
||||
|
@ -239,7 +239,7 @@ bool String::match_helper(const StringView& mask) const
|
|||
return false;
|
||||
|
||||
const char* string_ptr = characters();
|
||||
const char* mask_ptr = mask.characters();
|
||||
const char* mask_ptr = mask.characters_without_null_termination();
|
||||
const char* mask_end = mask_ptr + mask.length();
|
||||
|
||||
// Match string against mask directly unless we hit a *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue