]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
repobrowse: avoid extra hash assignments for Atom feed
authorEric Wong <e@80x24.org>
Sat, 21 Jan 2017 04:35:27 +0000 (04:35 +0000)
committerEric Wong <e@80x24.org>
Sat, 21 Jan 2017 04:35:27 +0000 (04:35 +0000)
This should make the code somewhat easier-to-follow.

lib/PublicInbox/RepobrowseGitAtom.pm

index 99d79869e8fbba1c88de1e9827a2ac799ad8093c..f851ee369268118cd9ad908105f2c4ffb479b931 100644 (file)
@@ -32,8 +32,8 @@ sub repo_root_url {
        PublicInbox::Repobrowse::base_url($env) . join('/', @uri);
 }
 
-sub flush_hdr ($$) {
-       my ($dst, $hdr) = @_;
+sub flush_hdr ($$$) {
+       my ($dst, $hdr, $url) = @_;
        $$dst .= '<entry><title>';
        $$dst .= utf8_html($hdr->{'s'}); # commit subject
        $$dst .= '</title><updated>';
@@ -46,8 +46,9 @@ sub flush_hdr ($$) {
        $$dst .= strftime(DATEFMT, gmtime($hdr->{at}));
        $$dst .= '</published>';
        $$dst .= qq(<link\nrel="alternate"\ntype="text/html"\nhref=");
-       $$dst .= $hdr->{url};
+       $$dst .= $url;
        $$dst .= '/commit?id=';
+
        my $H = $hdr->{H};
        $$dst .= $H;
        $$dst .= qq("\n/><id>);
@@ -73,7 +74,7 @@ sub git_atom_sed ($$) {
        my $title = join('/', $repo_info->{repo}, @{$req->{extra}});
        $title = utf8_html("$title, branch $req->{q}->{h}");
        my $url = repo_root_url($self, $req);
-       my $hdr = $req->{hdr} = { url => $url };
+       my $hdr = {};
        $req->{axml} = qq(<?xml version="1.0"?>\n) .
                qq(<feed\nxmlns="http://www.w3.org/2005/Atom">) .
                qq(<title>$title</title>) .
@@ -100,8 +101,8 @@ sub git_atom_sed ($$) {
                        if ($state != STATE_BODY) {
                                $hdr->{((STATES)[$state])} = $l;
                                if (++$state == STATE_BODY) {
-                                       flush_hdr(\$dst, $hdr);
-                                       %$hdr = (url => $url);
+                                       flush_hdr(\$dst, $hdr, $url);
+                                       $hdr = {};
                                }
                                next;
                        }