MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / findmk

Method findmk

core/string/ustring.cpp:3175–3228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3173}
3174
3175int String::findmk(const Vector<String> &p_keys, int p_from, int *r_key) const {
3176 if (p_from < 0) {
3177 return -1;
3178 }
3179 if (p_keys.is_empty()) {
3180 return -1;
3181 }
3182
3183 //int src_len=p_str.length();
3184 const String *keys = &p_keys[0];
3185 int key_count = p_keys.size();
3186 int len = length();
3187
3188 if (len == 0) {
3189 return -1; // won't find anything!
3190 }
3191
3192 const char32_t *src = get_data();
3193
3194 for (int i = p_from; i < len; i++) {
3195 bool found = true;
3196 for (int k = 0; k < key_count; k++) {
3197 found = true;
3198 if (r_key) {
3199 *r_key = k;
3200 }
3201 const char32_t *cmp = keys[k].get_data();
3202 int l = keys[k].length();
3203
3204 for (int j = 0; j < l; j++) {
3205 int read_pos = i + j;
3206
3207 if (read_pos >= len) {
3208 found = false;
3209 break;
3210 }
3211
3212 if (src[read_pos] != cmp[j]) {
3213 found = false;
3214 break;
3215 }
3216 }
3217 if (found) {
3218 break;
3219 }
3220 }
3221
3222 if (found) {
3223 return i;
3224 }
3225 }
3226
3227 return -1;
3228}
3229
3230int String::findn(const String &p_str, int p_from) const {
3231 if (p_from < 0) {

Callers 1

test_string.hFile · 0.80

Calls 5

get_dataFunction · 0.85
sizeMethod · 0.65
is_emptyMethod · 0.45
get_dataMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected