From: Vincent Pit Date: Thu, 22 Jul 2010 21:30:47 +0000 (+0200) Subject: Inline LaTeX::TikZ::Set->mods_unique X-Git-Tag: v0.01~6 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=3f51a1df8516c385856e6a8ae1000ed29906022f;p=perl%2Fmodules%2FLaTeX-TikZ.git Inline LaTeX::TikZ::Set->mods_unique --- diff --git a/lib/LaTeX/TikZ/Set.pm b/lib/LaTeX/TikZ/Set.pm index d4f67b6..e0886cb 100644 --- a/lib/LaTeX/TikZ/Set.pm +++ b/lib/LaTeX/TikZ/Set.pm @@ -56,8 +56,22 @@ sub mod { our %mods; our $last_mod = 0; - sub mods_unique { - my ($set) = @_; + around 'draw' => sub { + my ($orig, $set, $tikz) = @_; + + local $last_mod = $last_mod; + + # Save a deep copy + my %saved_idx = map { $_ => $#{$mods{$_}} } keys %mods; + my $guard = Scope::Guard->new(sub { + for (keys %mods) { + if (exists $saved_idx{$_}) { + $#{$mods{$_}} = $saved_idx{$_}; + } else { + delete $mods{$_}; + } + } + }); my (@mods, $last_layer); MOD: @@ -84,28 +98,6 @@ MOD: values %mods; } - return @mods; - } - - around 'draw' => sub { - my ($orig, $set, $tikz) = @_; - - local $last_mod = $last_mod; - - # Save a deep copy - my %saved_idx = map { $_ => $#{$mods{$_}} } keys %mods; - my $guard = Scope::Guard->new(sub { - for (keys %mods) { - if (exists $saved_idx{$_}) { - $#{$mods{$_}} = $saved_idx{$_}; - } else { - delete $mods{$_}; - } - } - }); - - my @mods = $set->mods_unique; - my $body = $set->$orig($tikz); if (@mods) {