From: Florian Ragwitz Date: Mon, 1 Oct 2012 01:29:16 +0000 (+0900) Subject: Factor out op class guessing X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2bc82b431ce11b4b9c75e39709e0c6bb0b405aeb;p=p5sagit%2FDevel-Size.git Factor out op class guessing Sometimes callers already know what kind of class the op they're dealing with belongs to. If they do, they can now just pass down that information into op_size_class, avoiding possibly wrong guesses from cc_opclass based on op_type. --- diff --git a/Memory.xs b/Memory.xs index 03426de..594565d 100644 --- a/Memory.xs +++ b/Memory.xs @@ -763,9 +763,17 @@ refcounted_he_size(pTHX_ struct state *st, struct refcounted_he *he, pPATH) refcounted_he_size(aTHX_ st, he->refcounted_he_next, NPathLink("refcounted_he_next")); } +static void op_size_class(pTHX_ const OP * const baseop, opclass op_class, struct state *st, pPATH); + static void op_size(pTHX_ const OP * const baseop, struct state *st, pPATH) { + op_size_class(aTHX_ baseop, cc_opclass(baseop), st, NPathArg); +} + +static void +op_size_class(pTHX_ const OP * const baseop, opclass op_class, struct state *st, pPATH) +{ /* op_size recurses to follow the chain of opcodes. For the node path we * don't want the chain to be 'nested' in the path so we use dNPathUseParent(). * Also, to avoid a link-to-a-link the caller should use NPathLinkAndNode() @@ -780,7 +788,7 @@ op_size(pTHX_ const OP * const baseop, struct state *st, pPATH) TAG; op_size(aTHX_ baseop->op_next, st, NPathOpLink); TAG; - switch (cc_opclass(baseop)) { + switch (op_class) { case OPc_BASEOP: TAG; ADD_SIZE(st, "op", sizeof(struct op)); TAG;break;