| 1332 | } |
| 1333 | |
| 1334 | String String::join(const Vector<String> &parts) const { |
| 1335 | if (parts.is_empty()) { |
| 1336 | return String(); |
| 1337 | } else if (parts.size() == 1) { |
| 1338 | return parts[0]; |
| 1339 | } |
| 1340 | |
| 1341 | const int this_length = length(); |
| 1342 | |
| 1343 | int new_size = (parts.size() - 1) * this_length; |
| 1344 | for (const String &part : parts) { |
| 1345 | new_size += part.length(); |
| 1346 | } |
| 1347 | new_size += 1; |
| 1348 | |
| 1349 | String ret; |
| 1350 | ret.resize_uninitialized(new_size); |
| 1351 | char32_t *ret_ptrw = ret.ptrw(); |
| 1352 | const char32_t *this_ptr = ptr(); |
| 1353 | |
| 1354 | bool first = true; |
| 1355 | for (const String &part : parts) { |
| 1356 | if (first) { |
| 1357 | first = false; |
| 1358 | } else if (this_length) { |
| 1359 | memcpy(ret_ptrw, this_ptr, this_length * sizeof(char32_t)); |
| 1360 | ret_ptrw += this_length; |
| 1361 | } |
| 1362 | |
| 1363 | const int part_length = part.length(); |
| 1364 | if (part_length) { |
| 1365 | memcpy(ret_ptrw, part.ptr(), part_length * sizeof(char32_t)); |
| 1366 | ret_ptrw += part_length; |
| 1367 | } |
| 1368 | } |
| 1369 | |
| 1370 | *ret_ptrw = 0; |
| 1371 | |
| 1372 | return ret; |
| 1373 | } |
| 1374 | |
| 1375 | char32_t String::char_uppercase(char32_t p_char) { |
| 1376 | return _find_upper(p_char); |