From 71040e5ff8a68eb0cfaf20c273e227cdceb9dc23 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 24 Aug 2015 02:25:46 +0000 Subject: view: refactor $state as a hash Using hash means we no longer have to document and remember what every field does. The original array form was insane premature optimization and crazy. Who wrote that? Oh wait, I was on drugs :< --- lib/PublicInbox/Feed.pm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/PublicInbox/Feed.pm') diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm index f4d19e02..969fc110 100644 --- a/lib/PublicInbox/Feed.pm +++ b/lib/PublicInbox/Feed.pm @@ -89,7 +89,12 @@ sub emit_html_index { $srch and $topics = [ [], {} ]; my (undef, $last) = each_recent_blob($ctx, sub { my ($path, $commit, $ts, $u, $subj) = @_; - $state ||= [ undef, {}, $commit, 0 ]; + $state ||= { + ctx => $ctx, + seen => {}, + first_commit => $commit, + anchor_idx => 0, + }; if ($srch) { add_topic($git, $srch, $topics, $path, $ts, $u, $subj); @@ -119,9 +124,8 @@ sub nav_footer { my $old_r = $cgi->param('r'); my $head = ' '; my $next = ' '; - # $state = [ undef, {}, $first_commit, $last_anchor ]; - my $first = $state->[2]; - my $anchor = $state->[3]; + my $first = $state->{first_commit}; + my $anchor = $state->{anchor_idx}; if ($last) { $next = qq!next!; -- cgit v1.2.3-24-ge0c7