mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
Make String::startsWith and String::lastIndexOf const. (#2646)
Co-authored-by: Grigory Shabaganov <gshabaganov@halfbrick.com>
This commit is contained in:
parent
c07d8a3bf4
commit
7672c4a32d
@ -179,7 +179,7 @@ namespace spine {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool startsWith(const String &needle) {
|
bool startsWith(const String &needle) const {
|
||||||
if (needle.length() > length()) return false;
|
if (needle.length() > length()) return false;
|
||||||
for (int i = 0; i < (int)needle.length(); i++) {
|
for (int i = 0; i < (int)needle.length(); i++) {
|
||||||
if (buffer()[i] != needle.buffer()[i]) return false;
|
if (buffer()[i] != needle.buffer()[i]) return false;
|
||||||
@ -187,7 +187,7 @@ namespace spine {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lastIndexOf(const char c) {
|
int lastIndexOf(const char c) const {
|
||||||
for (int i = (int)length() - 1; i >= 0; i--) {
|
for (int i = (int)length() - 1; i >= 0; i--) {
|
||||||
if (buffer()[i] == c) return i;
|
if (buffer()[i] == c) return i;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user