summaryrefslogtreecommitdiff
path: root/solenv/bin/modules
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2019-02-25 13:28:14 +0100
committerTomáš Chvátal <tchvatal@suse.cz>2019-02-25 16:25:10 +0100
commit6cf3f1fe4b77347f7b327f28e03941a95b9536b3 (patch)
tree3bc9670b9cc091fec9aabbb71c7f4c46599e38a8 /solenv/bin/modules
parent90372d52fdcc378473b89f4e6f2de0e206c110ef (diff)
Speed up languagepack installation
Reorder the order the filelists are initialized per package. Optimize speed of find_files_for_package: We can simply check if the modules entry is the same as last time. The code uses iterators instead of that C-ish for loops. Create a hash from the packagemodules to speed up the check if a module is included in the hash. Change-Id: I1e8ae394634a527880e08ef8ff333d94d04f49fd Before: 12s per language/package After: <1s per language/package Reviewed-on: https://gerrit.libreoffice.org/68339 Tested-by: Jenkins Reviewed-by: Tomáš Chvátal <tchvatal@suse.cz>
Diffstat (limited to 'solenv/bin/modules')
-rw-r--r--solenv/bin/modules/installer.pm26
-rw-r--r--solenv/bin/modules/installer/packagelist.pm52
2 files changed, 37 insertions, 41 deletions
diff --git a/solenv/bin/modules/installer.pm b/solenv/bin/modules/installer.pm
index 88ec4e9394f9..f7983673f2e8 100644
--- a/solenv/bin/modules/installer.pm
+++ b/solenv/bin/modules/installer.pm
@@ -998,14 +998,23 @@ sub run {
$packagerootpath = $installer::globals::rootpath;
}
+ #################################
+ # collecting items for package
+ #################################
+
+ my $filesinpackage = installer::packagelist::find_files_for_package($filesinproductlanguageresolvedarrayref, $onepackage);
+ my $unixlinksinpackage = installer::packagelist::find_files_for_package($unixlinksinproductlanguageresolvedarrayref, $onepackage);
+ my $linksinpackage = installer::packagelist::find_links_for_package($linksinproductlanguageresolvedarrayref, $onepackage);
+ my $dirsinpackage = installer::packagelist::find_dirs_for_package($directoriesforepmarrayref, $onepackage);
+
#############################################
# copying the collectors for each package
#############################################
- my $filesinpackage = installer::converter::copy_collector($filesinproductlanguageresolvedarrayref);
- my $linksinpackage = installer::converter::copy_collector($linksinproductlanguageresolvedarrayref);
- my $unixlinksinpackage = installer::converter::copy_collector($unixlinksinproductlanguageresolvedarrayref);
- my $dirsinpackage = installer::converter::copy_collector($directoriesforepmarrayref);
+ $filesinpackage = installer::converter::copy_collector($filesinpackage);
+ $linksinpackage = installer::converter::copy_collector($linksinpackage);
+ $unixlinksinpackage = installer::converter::copy_collector($unixlinksinpackage);
+ $dirsinpackage = installer::converter::copy_collector($dirsinpackage);
###########################################
# setting the root path for the packages
@@ -1016,15 +1025,6 @@ sub run {
installer::scriptitems::add_rootpath_to_links($linksinpackage, $packagerootpath);
installer::scriptitems::add_rootpath_to_files($unixlinksinpackage, $packagerootpath);
- #################################
- # collecting items for package
- #################################
-
- $filesinpackage = installer::packagelist::find_files_for_package($filesinpackage, $onepackage);
- $unixlinksinpackage = installer::packagelist::find_files_for_package($unixlinksinpackage, $onepackage);
- $linksinpackage = installer::packagelist::find_links_for_package($linksinpackage, $filesinpackage);
- $dirsinpackage = installer::packagelist::find_dirs_for_package($dirsinpackage, $onepackage);
-
###############################################
# nothing to do, if $filesinpackage is empty
###############################################
diff --git a/solenv/bin/modules/installer/packagelist.pm b/solenv/bin/modules/installer/packagelist.pm
index 14daf9907507..a0e1da760b44 100644
--- a/solenv/bin/modules/installer/packagelist.pm
+++ b/solenv/bin/modules/installer/packagelist.pm
@@ -239,47 +239,43 @@ sub find_files_for_package
{
my ($filelist, $onepackage) = @_;
- my @newfilelist = ();
+ my @newfilelist;
+ my $lastmodules = '';
+ my $lastincludefile = 0;
- for ( my $i = 0; $i <= $#{$filelist}; $i++ )
+ my %packagemodules = map {$_ => 1} @{$onepackage->{'allmodules'}};
+
+ for my $onefile (@$filelist)
{
- my $onefile = ${$filelist}[$i];
my $modulesstring = $onefile->{'modules'}; # comma separated modules list
+
+ # check if the modules string is the same as in the last file
+ if ($modulesstring eq $lastmodules)
+ {
+ push(@newfilelist, $onefile) if $lastincludefile;
+ next;
+ }
+
my $moduleslist = installer::converter::convert_stringlist_into_array(\$modulesstring, ",");
my $includefile = 0;
# iterating over all modules of this file
-
- for ( my $j = 0; $j <= $#{$moduleslist}; $j++ )
- {
- if ( $includefile ) { next; }
- my $filemodule = ${$moduleslist}[$j];
+ for my $filemodule (@$moduleslist) {
installer::remover::remove_leading_and_ending_whitespaces(\$filemodule);
-
- # iterating over all modules of the package
-
- my $packagemodules = $onepackage->{'allmodules'};
-
- for ( my $k = 0; $k <= $#{$packagemodules}; $k++ )
- {
- if ( $includefile ) { next; }
- my $packagemodule = ${$packagemodules}[$k];
-
- if ( $filemodule eq $packagemodule )
- {
- $includefile = 1;
- last;
- }
+ if ($packagemodules{$filemodule}) {
+ $includefile = 1;
+ last;
}
}
- if ( $includefile )
- {
- push(@newfilelist, $onefile);
- }
- }
+ push(@newfilelist, $onefile) if $includefile;
+
+ # cache last result for this modules list
+ $lastmodules = $modulesstring;
+ $lastincludefile = $includefile;
+ }
return \@newfilelist;
}