summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-12-12 23:22:05 +0000
committerKarl Berry <karl@freefriends.org>2019-12-12 23:22:05 +0000
commit7a9bf2feeb7d7b3a79b7003757fc7484ee980285 (patch)
treedd7eeba6133c89cd8c7dc32f91feb4a03963a06c /Master
parent91253010db384c5c2e2208fdd5f653d47db4ab26 (diff)
(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. git-svn-id: svn://tug.org/texlive/trunk@53111 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/tlpkg/TeXLive/TLUtils.pm11
1 files changed, 8 insertions, 3 deletions
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm
index f2a5b1ce093..c6ce5eaf07b 100644
--- a/Master/tlpkg/TeXLive/TLUtils.pm
+++ b/Master/tlpkg/TeXLive/TLUtils.pm
@@ -3612,15 +3612,20 @@ sub sort_uniq {
=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
+@ITEMS to the $LIST referenced by the first argument, if it is not
+already in the list.
=cut
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);
}
}