Fix string version of begins_with
Signed-off-by: Vinzenz Feenstra <evilissimo@gmail.com>
This commit is contained in:
parent
a9aae3000f
commit
bfa38b5166
1 changed files with 5 additions and 3 deletions
|
@ -2491,19 +2491,21 @@ bool String::begins_with(const String& p_string) const {
|
|||
const CharType *src=&p_string[0];
|
||||
const CharType *str=&operator[](0);
|
||||
|
||||
for (int i=0;i<l;i++) {
|
||||
int i = 0;
|
||||
for (;i<l;i++) {
|
||||
|
||||
if (src[i]!=str[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
// only if i == l the p_string matches the beginning
|
||||
return i == l;
|
||||
|
||||
}
|
||||
bool String::begins_with(const char* p_string) const {
|
||||
|
||||
int l=length();
|
||||
if (l==0)
|
||||
if (l==0||!p_string)
|
||||
return false;
|
||||
|
||||
const CharType *str=&operator[](0);
|
||||
|
|
Loading…
Reference in a new issue