diff --git a/src/profiler/configuration.c b/src/profiler/configuration.c index d6ff2940db..d4f8851336 100644 --- a/src/profiler/configuration.c +++ b/src/profiler/configuration.c @@ -143,6 +143,9 @@ static MVMuint8 operand_size(MVMThreadContext *tc, MVMuint8 operand) { case MVM_operand_obj: case MVM_operand_type_var: size = 2; break; + default: + MVM_exception_throw_adhoc(tc, "TODO: unknown operand type"); + /*fail(val, MSG(val, "unknown operand type %"PRIu32), type);*/ } } else { diff --git a/src/strings/ops.c b/src/strings/ops.c index e414ffa8b3..cb2c6a586e 100644 --- a/src/strings/ops.c +++ b/src/strings/ops.c @@ -546,11 +546,18 @@ static MVMint64 MVM_string_memmem_grapheme32str (MVMThreadContext *tc, MVMString MVMint64 rtrn; if (needle->body.storage_type != MVM_STRING_GRAPHEME_32) { MVMStringIndex i; - MVMGraphemeIter n_gi; needle_buf = MVM_malloc(needle->body.num_graphs * sizeof(MVMGrapheme32)); - if (needle->body.storage_type != MVM_STRING_GRAPHEME_8) MVM_string_gi_init(tc, &n_gi, needle); - for (i = 0; i < needle->body.num_graphs; i++) { - needle_buf[i] = needle->body.storage_type == MVM_STRING_GRAPHEME_8 ? needle->body.storage.blob_8[i] : MVM_string_gi_get_grapheme(tc, &n_gi); + if (needle->body.storage_type != MVM_STRING_GRAPHEME_8) { + MVMGraphemeIter n_gi; + MVM_string_gi_init(tc, &n_gi, needle); + for (i = 0; i < needle->body.num_graphs; i++) { + needle_buf[i] = MVM_string_gi_get_grapheme(tc, &n_gi); + } + } + else { + for (i = 0; i < needle->body.num_graphs; i++) { + needle_buf[i] = needle->body.storage.blob_8[i]; + } } } rtrn = MVM_string_memmem_grapheme32(tc, Haystack->body.storage.blob_32, needle_buf ? needle_buf : needle->body.storage.blob_32, H_start, H_graphs, n_graphs); @@ -593,20 +600,25 @@ MVMint64 MVM_string_index(MVMThreadContext *tc, MVMString *Haystack, MVMString * MVMGrapheme8 *needle_buf = NULL; if (needle->body.storage_type != MVM_STRING_GRAPHEME_8) { MVMStringIndex i; - MVMGraphemeIter n_gi; needle_buf = MVM_malloc(needle->body.num_graphs * sizeof(MVMGrapheme8)); - if (needle->body.storage_type != MVM_STRING_GRAPHEME_32) MVM_string_gi_init(tc, &n_gi, needle); - for (i = 0; i < needle->body.num_graphs; i++) { - MVMGrapheme32 g = needle->body.storage_type == MVM_STRING_GRAPHEME_32 - ? needle->body.storage.blob_32[i] - : MVM_string_gi_get_grapheme(tc, &n_gi); - /* Haystack is 8 bit, needle is 32 bit. if we encounter a non8bit grapheme - * it's impossible to match */ - if (!can_fit_into_8bit(g)) { - MVM_free(needle_buf); - return -1; + if (needle->body.storage_type != MVM_STRING_GRAPHEME_32) { + MVMGraphemeIter n_gi; + MVM_string_gi_init(tc, &n_gi, needle); + for (i = 0; i < needle->body.num_graphs; i++) { + needle_buf[i] = MVM_string_gi_get_grapheme(tc, &n_gi); + } + } + else { + for (i = 0; i < needle->body.num_graphs; i++) { + MVMGrapheme32 g = needle->body.storage.blob_32[i]; + /* Haystack is 8 bit, needle is 32 bit. if we encounter a non8bit grapheme + * it's impossible to match */ + if (!can_fit_into_8bit(g)) { + MVM_free(needle_buf); + return -1; + } + needle_buf[i] = g; } - needle_buf[i] = g; } } mm_return_8 = MVM_memmem(