summaryrefslogtreecommitdiffstats
path: root/core/string/ustring.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-03-05 23:44:46 +0100
committerRémi Verschelde <rverschelde@gmail.com>2024-03-05 23:44:46 +0100
commitdc55f8b6b23d63f4719f3a513429071bf7b19083 (patch)
tree6b9666fdd952db2c512d6d16797797f0f7b06614 /core/string/ustring.cpp
parent8b0eecdfae8f605d2b14dfd45922afaa52d6d84c (diff)
parent3026b566b0143977c1b184781ca9bcb37cac65b7 (diff)
downloadredot-engine-dc55f8b6b23d63f4719f3a513429071bf7b19083.tar.gz
Merge pull request #89194 from miv391/fix-string-begins-with
Fix `String::begins_with` when both strings are empty
Diffstat (limited to 'core/string/ustring.cpp')
-rw-r--r--core/string/ustring.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp
index f4b00255a1..1d27933016 100644
--- a/core/string/ustring.cpp
+++ b/core/string/ustring.cpp
@@ -3329,10 +3329,14 @@ bool String::begins_with(const String &p_string) const {
bool String::begins_with(const char *p_string) const {
int l = length();
- if (l == 0 || !p_string) {
+ if (!p_string) {
return false;
}
+ if (l == 0) {
+ return *p_string == 0;
+ }
+
const char32_t *str = &operator[](0);
int i = 0;