Skip to content

Instantly share code, notes, and snippets.

@MasterDuke17
Created August 19, 2024 00:11
Show Gist options
  • Select an option

  • Save MasterDuke17/e0de6ce36cd3e945d7c4f274ed02e4b5 to your computer and use it in GitHub Desktop.

Select an option

Save MasterDuke17/e0de6ce36cd3e945d7c4f274ed02e4b5 to your computer and use it in GitHub Desktop.
diff --git src/6model/reprs/NFA.c src/6model/reprs/NFA.c
index fc102f639..bc76fdb05 100644
--- src/6model/reprs/NFA.c
+++ src/6model/reprs/NFA.c
@@ -883,7 +883,7 @@ MVMObject * MVM_nfa_run_proto(MVMThreadContext *tc, MVMObject *nfa, MVMString *t
MVMint64 *fates = nqp_nfa_run(tc, (MVMNFABody *)OBJECT_BODY(nfa), target, offset, &total_fates);
/* Copy results into an integer array. */
- MVMObject *fateres = MVM_repr_alloc_init(tc, tc->instance->boot_types.BOOTIntArray);
+ MVMObject *fateres = total_fates ? MVM_repr_alloc_init(tc, tc->instance->boot_types.BOOTIntArray) : tc->instance->VMNull;
for (i = 0; i < total_fates; i++)
MVM_repr_bind_pos_i(tc, fateres, i, fates[i]);
diff --git src/QRegex/Cursor.nqp src/QRegex/Cursor.nqp
index b175285ad..575f8888f 100644
--- src/QRegex/Cursor.nqp
+++ src/QRegex/Cursor.nqp
@@ -737,7 +737,7 @@ role NQPMatchRole is export {
self.HOW.cache_add(self, $name, $nfa);
}
- my @fates := $nfa.run(
+ my $fates := $nfa.run(
nqp::getattr_s($shared, ParseShared, '$!target'), $pos
);
@@ -751,11 +751,13 @@ role NQPMatchRole is export {
my $rxname;
# Check all the fates
- while nqp::elems(@fates) {
- $rxname := nqp::atpos(@rxfate, nqp::pop_i(@fates));
- # note("invoking $rxname");
- $cur := self."$rxname"();
- @fates := $EMPTY if nqp::getattr_i($cur, $?CLASS, '$!pos') >= 0;
+ if !nqp::isnull($fates) {
+ while nqp::elems($fates) {
+ $rxname := nqp::atpos(@rxfate, nqp::pop_i($fates));
+ # note("invoking $rxname");
+ $cur := self."$rxname"();
+ last if nqp::getattr_i($cur, $?CLASS, '$!pos') >= -1;
+ }
}
$cur // nqp::getattr($shared, ParseShared, '$!fail_cursor');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment