From: Tim Bunce Date: Tue, 2 Oct 2012 16:34:00 +0000 (+0100) Subject: Remove 'pre attr'. Other minor cleanup. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=957d176be7818eb52e035c3f6842344b38e9c177;p=p5sagit%2FDevel-Size.git Remove 'pre attr'. Other minor cleanup. --- diff --git a/SizeMe.xs b/SizeMe.xs index cdedaf7..87f1041 100644 --- a/SizeMe.xs +++ b/SizeMe.xs @@ -3,15 +3,8 @@ /* TODO * * Refactor this to split out D:M code from Devel::Size code. - * * Start migrating Devel::Size's Size.xs towards the new code. * - * ADD_PRE_ATTR for index should check if the ptr is new first. Currently we're - * generating lots of ADD_PRE_ATTR's for SVs that we've already seen via other paths. - * That's wasteful and likely to cause subtle bugs. - * - * Give HE's their own node so keys and values can be tied together - * */ #undef NDEBUG /* XXX */ @@ -174,14 +167,13 @@ struct state { #define NPtype_MAGIC 0x04 #define NPtype_OP 0x05 -/* XXX these should probably be generalizes into flag bits */ +/* XXX these should probably be generalized into flag bits */ #define NPattr_LEAFSIZE 0x00 #define NPattr_NAME 0x01 #define NPattr_PADFAKE 0x02 #define NPattr_PADNAME 0x03 #define NPattr_PADTMP 0x04 #define NPattr_NOTE 0x05 -#define NPattr_PRE_ATTR 0x06 /* deprecated */ #define _ADD_ATTR_NP(st, attr_type, attr_name, attr_value, np) \ STMT_START { \ @@ -190,17 +182,14 @@ struct state { } \ } STMT_END -#define ADD_ATTR(st, attr_type, attr_name, attr_value) _ADD_ATTR_NP(st, attr_type, attr_name, attr_value, NP-1) +#define ADD_ATTR(st, attr_type, attr_name, attr_value) \ + _ADD_ATTR_NP(st, attr_type, attr_name, attr_value, NP-1) + #define ADD_LINK_ATTR(st, attr_type, attr_name, attr_value) \ STMT_START { \ assert(NP->seqn); \ _ADD_ATTR_NP(st, attr_type, attr_name, attr_value, NP); \ } STMT_END; -#define ADD_PRE_ATTR(st, attr_type, attr_name, attr_value) \ - STMT_START { \ - assert(!attr_type); \ - _ADD_ATTR_NP(st, NPattr_PRE_ATTR, attr_name, attr_value, NP-1); \ - } STMT_END; #define _NPathLink(np, nid, ntype) (((np)->id=nid), ((np)->type=ntype), ((np)->seqn=0)) #define NPathLink(nid) (_NPathLink(NP, nid, NPtype_LINK), NP) @@ -763,14 +752,14 @@ regex_size(pTHX_ const REGEXP * const baseregex, struct state *st, pPATH) { } } -static void +static int hek_size(pTHX_ struct state *st, HEK *hek, U32 shared, pPATH) { dNPathNodes(1, NPathArg); /* Hash keys can be shared. Have we seen this before? */ if (!check_new(st, hek)) - return; + return 0; NPathPushNode("hek", NPtype_NAME); ADD_SIZE(st, "hek_len", HEK_BASESIZE + hek->hek_len #if PERL_VERSION < 8 @@ -786,6 +775,7 @@ hek_size(pTHX_ struct state *st, HEK *hek, U32 shared, pPATH) ADD_SIZE(st, "shared_he", STRUCT_OFFSET(struct shared_he, shared_he_hek)); #endif } + return 1; } static void diff --git a/bin/sizeme_store.pl b/bin/sizeme_store.pl index f9f7e65..9a8d889 100755 --- a/bin/sizeme_store.pl +++ b/bin/sizeme_store.pl @@ -208,7 +208,6 @@ sub leave_node { } my $indent = ": "; -my $pending_pre_attr = {}; while (<>) { warn "\t\t\t\t== $_" if $opt_debug; @@ -234,10 +233,8 @@ while (<>) { die "Depth out of sync\n" if $val != @stack; my $node = enter_node({ id => $id, type => $type, name => $name, extra => $extra, - attr => { %$pending_pre_attr }, - leaves => {}, depth => $val, self_size=>0, kids_size=>0 + attr => { }, leaves => {}, depth => $val, self_size=>0, kids_size=>0 }); - %$pending_pre_attr = (); $stack[$val] = $node; $seqn2node{$id} = $node; } @@ -256,12 +253,8 @@ while (<>) { my $node = $seqn2node{$id} || die; my $attr = $node->{attr} || die; - # attributes to queue up and apply to the next node - if (NPattr_PRE_ATTR == $type) { - $pending_pre_attr->{$name} = $val; - } # attributes where the string is a key (or always empty and the type is the key) - elsif ($type == NPattr_NAME or $type == NPattr_NOTE) { + if ($type == NPattr_NAME or $type == NPattr_NOTE) { printf "%s~%s(%s) %d [t%d]\n", $indent x ($node->{depth}+1), $attr_type_name[$type], $name, $val, $type if $opt_text; warn "Node $id already has attribute $type:$name (value $attr->{$type}{$name})\n" @@ -341,7 +334,6 @@ while (<>) { } die "panic: seqn2node should be empty ". Dumper(\%seqn2node) if %seqn2node; - %$pending_pre_attr = (); if ($dot_fh) { print $dot_fh "}\n";