Skip to content

Commit

Permalink
Speedup of valuator: t+
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffrey Kegler committed Feb 7, 2013
1 parent 752b4c6 commit 6d20e44
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions r2/xs/R2.xs
Expand Up @@ -2110,6 +2110,34 @@ PPCODE:
XSRETURN_YES;
}

void
rule_register( v_wrapper, rule_id, ... )
V_Wrapper *v_wrapper;
Marpa_Rule_ID rule_id;
PPCODE:
{
/* OP Count is args less two */
const STRLEN op_count = items - 2;
STRLEN op_ix;
STRLEN dummy;
UV *ops;
SV *ops_sv;
AV *rule_semantics = v_wrapper->rule_semantics;

if (!rule_semantics)
{
croak ("Problem in v->rule_register(): valuator is not in stack mode");
}
ops_sv = newSV (op_count * sizeof (UV));
SvPOK_on (ops_sv);
ops = (UV *) SvPV (ops_sv, dummy);
for (op_ix = 2; op_ix < op_count; op_ix++)
{
ops[op_ix - 2] = SvUV (ST (op_ix));
}
av_store (rule_semantics, (I32) rule_id, op_sv);
}

void
highest_index( v_wrapper )
V_Wrapper *v_wrapper;
Expand Down

0 comments on commit 6d20e44

Please sign in to comment.