texlive[53111] Master/tlpkg/TeXLive/TLUtils.pm: (push_uniq): do
commits+karl at tug.org
commits+karl at tug.org
Fri Dec 13 00:22:05 CET 2019
Revision: 53111
http://tug.org/svn/texlive?view=revision&revision=53111
Author: karl
Date: 2019-12-13 00:22:05 +0100 (Fri, 13 Dec 2019)
Log Message:
-----------
(push_uniq): do member test inline instead of
calling member() function; this is part of an
inner loop in tl-update-tlpdb and the subroutine
call overhead is significant. Saves 30-40 seconds.
Modified Paths:
--------------
trunk/Master/tlpkg/TeXLive/TLUtils.pm
Modified: trunk/Master/tlpkg/TeXLive/TLUtils.pm
===================================================================
--- trunk/Master/tlpkg/TeXLive/TLUtils.pm 2019-12-12 23:16:59 UTC (rev 53110)
+++ trunk/Master/tlpkg/TeXLive/TLUtils.pm 2019-12-12 23:22:05 UTC (rev 53111)
@@ -3612,8 +3612,9 @@
=item C<push_uniq(\@list, @new_items)>
-The C<push_uniq> function pushes the last argument @ITEMS to the $LIST
-referenced by the first argument, if they are not already in the list.
+The C<push_uniq> function pushes each element in the last argument
+ at ITEMS to the $LIST referenced by the first argument, if it is not
+already in the list.
=cut
@@ -3620,7 +3621,11 @@
sub push_uniq {
my ($l, @new_items) = @_;
for my $e (@new_items) {
- if (! &member($e, @$l)) {
+ # turns out this is one of the most-used functions when updating the
+ # tlpdb, with hundreds of thousands of calls. So let's write it out
+ # to eliminate the sub overhead.
+ #if (! &member($e, @$l)) {
+ if (! scalar grep($_ eq $e, @$l)) {
push (@$l, $e);
}
}
More information about the tex-live-commits
mailing list