* [PATCH 16/18] viewvcs: reduce hash assignments for commit info
2022-08-29 9:26 6% [PATCH 00/18] WWW: patch, tree, git glossary Eric Wong
@ 2022-08-29 9:26 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2022-08-29 9:26 UTC (permalink / raw)
To: meta
This makes some of the associated code less verbose and
easier-to-read IMHO.
---
lib/PublicInbox/ViewVCS.pm | 33 +++++++++++++++------------------
1 file changed, 15 insertions(+), 18 deletions(-)
diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm
index a5545bcd..0a38f9de 100644
--- a/lib/PublicInbox/ViewVCS.pm
+++ b/lib/PublicInbox/ViewVCS.pm
@@ -136,8 +136,7 @@ sub show_commit_start { # ->psgi_qx callback
chop(my $buf = do { local $/ = "\0"; <$fh> });
chomp $buf;
my ($P, $p);
- ($P, $p, @$ctx{qw(cmt_H cmt_T cmt_s cmt_f cmt_au cmt_co cmt_b)})
- = split(/\n/, $buf, 9);
+ ($P, $p, @{$ctx->{cmt_info}}) = split(/\n/, $buf, 9);
return cmt_finalize($ctx) if !$P;
@{$ctx->{-cmt_P}} = split(/ /, $P);
@{$ctx->{-cmt_p}} = split(/ /, $p); # abbreviated
@@ -157,8 +156,8 @@ sub cmt_finalize {
my ($ctx) = @_;
$ctx->{-linkify} //= PublicInbox::Linkify->new;
my $upfx = $ctx->{-upfx} = '../../'; # from "/$INBOX/$OID/s/"
+ my ($H, $T, $s, $f, $au, $co, $bdy) = @{delete $ctx->{cmt_info}};
# try to keep author and committer dates lined up
- my ($au, $co) = delete @$ctx{qw(cmt_au cmt_co)};
my $x = length($au) - length($co);
if ($x > 0) {
$x = ' ' x $x;
@@ -175,13 +174,12 @@ sub cmt_finalize {
href="$upfx?t=$t"
title="list contemporary emails">$2</a>)
!e;
- my $s = $ctx->{-linkify}->to_html(delete $ctx->{cmt_s});
- $ctx->{-title_html} = $s;
+ $ctx->{-title_html} = $s = $ctx->{-linkify}->to_html($s);
my ($P, $p, $pt) = delete @$ctx{qw(-cmt_P -cmt_p -cmt_pt)};
$_ = qq(<a href="$upfx$_/s/">).shift(@$p).'</a> '.shift(@$pt) for @$P;
if (@$P == 1) {
$x = qq{ (<a
-href="$ctx->{cmt_f}.patch">patch</a>)\n parent $P->[0]};
+href="$f.patch">patch</a>)\n parent $P->[0]};
} elsif (@$P > 1) {
$x = qq(\n parents $P->[0]\n);
shift @$P;
@@ -192,29 +190,28 @@ href="$ctx->{cmt_f}.patch">patch</a>)\n parent $P->[0]};
}
PublicInbox::WwwStream::html_init($ctx);
$ctx->zmore(<<EOM);
-<pre> commit $ctx->{cmt_H}$x
- tree <a href="$upfx$ctx->{cmt_T}/s/">$ctx->{cmt_T}</a>
+<pre> commit $H$x
+ tree <a href="$upfx$T/s/">$T</a>
author $au
committer $co
<b>$s</b>
EOM
- $x = delete $ctx->{cmt_b};
- $ctx->zmore("\n", $ctx->{-linkify}->to_html($x)) if length($x);
- undef $x;
+ $ctx->zmore("\n", $ctx->{-linkify}->to_html($bdy)) if length($bdy);
+ $bdy = '';
open my $fh, '<:utf8', "$ctx->{-tmp}/p" or
die "open $ctx->{-tmp}/p: $!";
if (-s $fh > $MAX_SIZE) {
$ctx->zmore("---\n patch is too large to show\n");
} else { # prepare flush_diff:
- $ctx->{obuf} = \$x;
+ read($fh, $x, -s _);
+ $ctx->{obuf} = \$bdy;
$ctx->{-apfx} = $ctx->{-spfx} = $upfx;
- read($fh, my $bdy, -s _);
- $bdy =~ s/\r?\n/\n/gs;
- $ctx->{-anchors} = {} if $bdy =~ /^diff --git /sm;
- flush_diff($ctx, \$bdy); # undefs $bdy
- $ctx->zmore($x);
- undef $x;
+ $x =~ s/\r?\n/\n/gs;
+ $ctx->{-anchors} = {} if $x =~ /^diff --git /sm;
+ flush_diff($ctx, \$x); # undefs $x
+ $ctx->zmore($bdy);
+ undef $bdy;
# TODO: should there be another textarea which attempts to
# search for the exact email which was applied to make this
# commit?
^ permalink raw reply related [relevance 7%]
* [PATCH 00/18] WWW: patch, tree, git glossary
@ 2022-08-29 9:26 6% Eric Wong
2022-08-29 9:26 7% ` [PATCH 16/18] viewvcs: reduce hash assignments for commit info Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2022-08-29 9:26 UTC (permalink / raw)
To: meta
Raw format-patch and tree HTML output now supported for git
output. I suppose tags can be displayed, too, at some point...
One thing I'm not 100% sure about is adding a git-related
glossary for stuff like trees, commits, etc... It seems
to bloat the page a bit, but it could be useful in slowly
teaching basic git data concepts to beginners.
I suspect folks who have trouble learning git too focused on the
commands rather than the data concepts. (IMHO, the same goes
for learning projects based on studying code vs studying
(DB schemas || struct layouts)).
I snuck one speedup in there, hopefully more to come...
Eric Wong (18):
solver: create tmpdir lazily
viewvcs: share File::Temp::Dir with solver
viewvcs: delay stringification of solver debug log
www: allow html_oneshot to take an array arg
viewvcs: use array for highlighted blob display
viewvcs: add patch download link for single-parent commits
viewvcs: author date links to contemporary messages
view: speed up /$INBOX/ landing page by 0.5-1.0%
treewide: ditch inbox->recent method
view: /$INBOX/: show "messages from $old to $new"
view: cleanups and reuse for {obuf} preparation
www: atom: fix "changed" href to nowhere
www: provide text/help/#search anchor
solver: early make hints detection more robust
viewvcs: add tree view
viewvcs: reduce hash assignments for commit info
viewvcs: add glossary for commit
viewvcs: show "blob $OID" rather than "$OID blob"
lib/PublicInbox/ExtSearch.pm | 1 -
lib/PublicInbox/Inbox.pm | 5 -
lib/PublicInbox/LeiSavedSearch.pm | 1 -
lib/PublicInbox/LeiXSearch.pm | 7 -
lib/PublicInbox/SolverGit.pm | 22 +-
lib/PublicInbox/View.pm | 101 ++++-----
lib/PublicInbox/ViewDiff.pm | 18 +-
lib/PublicInbox/ViewVCS.pm | 341 ++++++++++++++++++++----------
lib/PublicInbox/WWW.pm | 2 +-
lib/PublicInbox/WwwAltId.pm | 6 +-
lib/PublicInbox/WwwAtomStream.pm | 1 +
lib/PublicInbox/WwwStream.pm | 7 +-
lib/PublicInbox/WwwText.pm | 3 +-
t/convert-compact.t | 2 +-
t/indexlevels-mirror.t | 10 +-
t/lei_xsearch.t | 2 +-
t/plack.t | 2 +-
t/replace.t | 4 +-
t/solver_git.t | 3 +-
t/v1-add-remove-add.t | 2 +-
t/v2-add-remove-add.t | 2 +-
21 files changed, 333 insertions(+), 209 deletions(-)
^ permalink raw reply [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2022-08-29 9:26 6% [PATCH 00/18] WWW: patch, tree, git glossary Eric Wong
2022-08-29 9:26 7% ` [PATCH 16/18] viewvcs: reduce hash assignments for commit info Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).