summaryrefslogtreecommitdiff
path: root/AK/String.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-08 15:38:44 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-08 15:38:44 +0200
commit0e75aba7c39c7a2d3b0becc2416aa0e251d62070 (patch)
tree19bc08a69423db6ab1c6669c06eaab81f494a564 /AK/String.cpp
parent567551bc12945c25b49c65579ceb545668dbb7eb (diff)
downloadserenity-0e75aba7c39c7a2d3b0becc2416aa0e251d62070.zip
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.
Diffstat (limited to 'AK/String.cpp')
-rw-r--r--AK/String.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/AK/String.cpp b/AK/String.cpp
index 4657835b8d..4f8d230259 100644
--- a/AK/String.cpp
+++ b/AK/String.cpp
@@ -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 *