Skip to content

Instantly share code, notes, and snippets.

@samcv
Created August 17, 2017 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samcv/49edd75afe6fc4a84852f8605d99e6b0 to your computer and use it in GitHub Desktop.
Save samcv/49edd75afe6fc4a84852f8605d99e6b0 to your computer and use it in GitHub Desktop.
/* Returns the codepoint from grapheme iterator at a specific location without doing checks, for internal VM use only. */
MVMGrapheme32 MVM_string_gi_get_grapheme_at(MVMThreadContext *tc, MVMString *a, MVMGraphemeIter *gi, MVMint64 index) {
switch (a->body.storage_type) {
case MVM_STRING_GRAPHEME_32:
return a->body.storage.blob_32[index];
case MVM_STRING_GRAPHEME_ASCII:
return a->body.storage.blob_ascii[index];
case MVM_STRING_GRAPHEME_8:
return a->body.storage.blob_8[index];
case MVM_STRING_STRAND: {
MVM_string_gi_move_to(tc, gi, index);
return MVM_string_gi_get_grapheme(tc, gi);
}
default:
MVM_exception_throw_adhoc(tc, "String corruption detected: bad storage type");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment