From 7a9bf2feeb7d7b3a79b7003757fc7484ee980285 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 12 Dec 2019 23:22:05 +0000 Subject: (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 --- Master/tlpkg/TeXLive/TLUtils.pm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'Master/tlpkg/TeXLive/TLUtils.pm') 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 -The C function pushes the last argument @ITEMS to the $LIST -referenced by the first argument, if they are not already in the list. +The C 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); } } -- cgit v1.2.3