MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / get_message_multipart_str

Method get_message_multipart_str

compat/optimized_translation_extractor.cpp:365–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

363}
364
365String OptimizedTranslationExtractor::get_message_multipart_str(const char *part1, const char *part2, const char *part3, const char *part4, const char *part5, const char *part6) const {
366 int htsize = hash_table.size();
367
368 if (htsize == 0) {
369 return StringName();
370 }
371 uint32_t h = hash_multipart(0, part1, part2, part3, part4, part5, part6);
372 const int *htr = hash_table.ptr();
373 const uint32_t *htptr = (const uint32_t *)&htr[0];
374 const int *btr = bucket_table.ptr();
375 const uint32_t *btptr = (const uint32_t *)&btr[0];
376 const uint8_t *sr = strings.ptr();
377 const char *sptr = (const char *)&sr[0];
378
379 uint32_t p = htptr[h % htsize];
380
381 if (p == 0xFFFFFFFF) {
382 return StringName(); //nothing
383 }
384
385 const Bucket &bucket = *(const Bucket *)&btptr[p];
386
387 h = hash_multipart(bucket.func, part1, part2, part3, part4, part5, part6);
388
389 int idx = -1;
390
391 for (int i = 0; i < bucket.size; i++) {
392 if (bucket.elem[i].key == h) {
393 idx = i;
394 break;
395 }
396 }
397
398 if (idx == -1) {
399 return StringName();
400 }
401
402 if (bucket.elem[idx].comp_size == bucket.elem[idx].uncomp_size) {
403 String rstr;
404 rstr.append_utf8(&sptr[bucket.elem[idx].str_offset], bucket.elem[idx].uncomp_size);
405
406 return rstr;
407 } else {
408 CharString uncomp;
409 uncomp.resize_uninitialized(bucket.elem[idx].uncomp_size + 1);
410 smaz_decompress(&sptr[bucket.elem[idx].str_offset], bucket.elem[idx].comp_size, uncomp.ptrw(), bucket.elem[idx].uncomp_size);
411 String rstr;
412 rstr.append_utf8(uncomp.get_data());
413 return rstr;
414 }
415}
416
417String OptimizedTranslationExtractor::get_message_str(const StringName &p_src_text) const {
418 return get_message_str(p_src_text.operator String().utf8().get_data());

Callers 1

try_key_multipartMethod · 0.80

Calls 2

sizeMethod · 0.45
get_dataMethod · 0.45

Tested by

no test coverage detected