Filename | /cygdrive/c/lo/libo-master/instsetoo_native/util/C:/lo/libo-master/solenv/bin/modules/installer/scpzipfiles.pm |
Statements | Executed 349317 statements in 1.23s |
While profiling this file Perl noted the use of one or more special variables that impact the performance of all regular expressions in the program.
Use of the "$`", "$&", and "$'" variables should be replaced with faster alternatives.
See the WARNING at the end of the
Capture Buffers section of the perlre documentation.
The use is detected by perl at compile time but by NYTProf during execution. NYTProf first noted it when executing line 34. That was probably the first statement executed by the program after perl compiled the code containing the variables. If the variables can't be found by studying the source code, try using the Devel::FindAmpersand or B::Lint modules.
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
112 | 3 | 2 | 930ms | 1.11s | replace_all_ziplistvariables_in_file | installer::scpzipfiles::
283508 | 1 | 1 | 154ms | 154ms | CORE:subst (opcode) | installer::scpzipfiles::
2 | 2 | 1 | 115ms | 1.42s | resolving_scpzip_replace_flag | installer::scpzipfiles::
9109 | 1 | 1 | 25.7ms | 25.7ms | CORE:substcont (opcode) | installer::scpzipfiles::
16005 | 2 | 1 | 7.71ms | 7.71ms | CORE:match (opcode) | installer::scpzipfiles::
1 | 1 | 1 | 347µs | 350µs | BEGIN@30 | installer::scpzipfiles::
110 | 1 | 1 | 202µs | 202µs | CORE:regcomp (opcode) | installer::scpzipfiles::
1 | 1 | 1 | 19µs | 49µs | BEGIN@32 | installer::scpzipfiles::
1 | 1 | 1 | 16µs | 18µs | BEGIN@34 | installer::scpzipfiles::
1 | 1 | 1 | 15µs | 17µs | BEGIN@31 | installer::scpzipfiles::
1 | 1 | 1 | 14µs | 16µs | BEGIN@33 | installer::scpzipfiles::
0 | 0 | 0 | 0s | 0s | replace_all_ziplistvariables_in_rtffile | installer::scpzipfiles::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | #************************************************************************* | ||||
2 | # | ||||
3 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||||
4 | # | ||||
5 | # Copyright 2000, 2010 Oracle and/or its affiliates. | ||||
6 | # | ||||
7 | # OpenOffice.org - a multi-platform office productivity suite | ||||
8 | # | ||||
9 | # This file is part of OpenOffice.org. | ||||
10 | # | ||||
11 | # OpenOffice.org is free software: you can redistribute it and/or modify | ||||
12 | # it under the terms of the GNU Lesser General Public License version 3 | ||||
13 | # only, as published by the Free Software Foundation. | ||||
14 | # | ||||
15 | # OpenOffice.org is distributed in the hope that it will be useful, | ||||
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
18 | # GNU Lesser General Public License version 3 for more details | ||||
19 | # (a copy is included in the LICENSE file that accompanied this code). | ||||
20 | # | ||||
21 | # You should have received a copy of the GNU Lesser General Public License | ||||
22 | # version 3 along with OpenOffice.org. If not, see | ||||
23 | # <http://www.openoffice.org/license.html> | ||||
24 | # for a copy of the LGPLv3 License. | ||||
25 | # | ||||
26 | #************************************************************************* | ||||
27 | |||||
28 | package installer::scpzipfiles; | ||||
29 | |||||
30 | 2 | 60µs | 2 | 353µs | # spent 350µs (347+3) within installer::scpzipfiles::BEGIN@30 which was called:
# once (347µs+3µs) by installer::worker::BEGIN@42 at line 30 # spent 350µs making 1 call to installer::scpzipfiles::BEGIN@30
# spent 3µs making 1 call to UNIVERSAL::import |
31 | 2 | 62µs | 2 | 20µs | # spent 17µs (15+3) within installer::scpzipfiles::BEGIN@31 which was called:
# once (15µs+3µs) by installer::worker::BEGIN@42 at line 31 # spent 17µs making 1 call to installer::scpzipfiles::BEGIN@31
# spent 3µs making 1 call to UNIVERSAL::import |
32 | 2 | 54µs | 2 | 79µs | # spent 49µs (19+30) within installer::scpzipfiles::BEGIN@32 which was called:
# once (19µs+30µs) by installer::worker::BEGIN@42 at line 32 # spent 49µs making 1 call to installer::scpzipfiles::BEGIN@32
# spent 30µs making 1 call to Exporter::import |
33 | 2 | 52µs | 2 | 18µs | # spent 16µs (14+2) within installer::scpzipfiles::BEGIN@33 which was called:
# once (14µs+2µs) by installer::worker::BEGIN@42 at line 33 # spent 16µs making 1 call to installer::scpzipfiles::BEGIN@33
# spent 2µs making 1 call to UNIVERSAL::import |
34 | 2 | 1.03ms | 2 | 21µs | # spent 18µs (16+3) within installer::scpzipfiles::BEGIN@34 which was called:
# once (16µs+3µs) by installer::worker::BEGIN@42 at line 34 # spent 18µs making 1 call to installer::scpzipfiles::BEGIN@34
# spent 3µs making 1 call to UNIVERSAL::import |
35 | |||||
36 | # Replacing all zip list variables. | ||||
37 | # Called for setup script as well as files with flag scpzip_replace. | ||||
38 | |||||
39 | sub replace_all_ziplistvariables_in_file | ||||
40 | # spent 1.11s (930ms+180ms) within installer::scpzipfiles::replace_all_ziplistvariables_in_file which was called 112 times, avg 9.91ms/call:
# 110 times (114ms+52.7ms) by installer::scpzipfiles::resolving_scpzip_replace_flag at line 135, avg 1.52ms/call
# once (412ms+63.4ms) by installer::run at line 350 of /cygdrive/c/lo/libo-master/instsetoo_native/util/C:/lo/libo-master/solenv/bin/modules/installer.pm
# once (404ms+63.8ms) by installer::run at line 326 of /cygdrive/c/lo/libo-master/instsetoo_native/util/C:/lo/libo-master/solenv/bin/modules/installer.pm | ||||
41 | 224 | 832µs | my ( $fileref, $variablesref ) = @_; | ||
42 | |||||
43 | for my $line ( @{$fileref} ) | ||||
44 | { | ||||
45 | # Avoid removing variables we do not recognise. | ||||
46 | 283508 | 1.11s | 292617 | 180ms | $line =~ s/\$\{(\w+)\}/defined $variablesref->{$1} # spent 154ms making 283508 calls to installer::scpzipfiles::CORE:subst, avg 544ns/call
# spent 25.7ms making 9109 calls to installer::scpzipfiles::CORE:substcont, avg 3µs/call |
47 | ? $variablesref->{$1} | ||||
48 | : $&/eg; | ||||
49 | } | ||||
50 | } | ||||
51 | |||||
52 | # Replacing all zip list variables in rtf files. | ||||
53 | |||||
54 | sub replace_all_ziplistvariables_in_rtffile | ||||
55 | { | ||||
56 | my ( $fileref, $variablesref ) = @_; | ||||
57 | |||||
58 | for my $line ( @{$fileref} ) | ||||
59 | { | ||||
60 | # In rtf files the braces are backslash-escaped. | ||||
61 | # Avoid removing variables we do not recognise. | ||||
62 | $line =~ s/\$\\\{(\w+)\\\}/defined $variablesref->{$1} | ||||
63 | ? $variablesref->{$1} | ||||
64 | : $&/eg; | ||||
65 | } | ||||
66 | } | ||||
67 | |||||
68 | ######################################################### | ||||
69 | # Analyzing files with flag SCPZIP_REPLACE | ||||
70 | # $item can be "File" or "ScpAction" | ||||
71 | ######################################################### | ||||
72 | |||||
73 | sub resolving_scpzip_replace_flag | ||||
74 | # spent 1.42s (115ms+1.30) within installer::scpzipfiles::resolving_scpzip_replace_flag which was called 2 times, avg 708ms/call:
# once (115ms+1.01s) by installer::run at line 713 of /cygdrive/c/lo/libo-master/instsetoo_native/util/C:/lo/libo-master/solenv/bin/modules/installer.pm
# once (38µs+289ms) by installer::run at line 762 of /cygdrive/c/lo/libo-master/instsetoo_native/util/C:/lo/libo-master/solenv/bin/modules/installer.pm | ||||
75 | 14 | 17.8ms | my ($filesarrayref, $variableshashref, $item, $languagestringref) = @_; | ||
76 | |||||
77 | my $diritem = lc($item); | ||||
78 | |||||
79 | 2 | 558ms | my $replacedirbase = installer::systemactions::create_directories("replace_$diritem", $languagestringref); # spent 558ms making 2 calls to installer::systemactions::create_directories, avg 279ms/call | ||
80 | |||||
81 | 2 | 320µs | installer::logger::include_header_into_logfile("$item with flag SCPZIP:"); # spent 320µs making 2 calls to installer::logger::include_header_into_logfile, avg 160µs/call | ||
82 | |||||
83 | 63580 | 90.5ms | for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ ) | ||
84 | { | ||||
85 | my $onefile = ${$filesarrayref}[$i]; | ||||
86 | my $styles = ""; | ||||
87 | |||||
88 | if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; } | ||||
89 | |||||
90 | 1650 | 3.66ms | 15895 | 7.55ms | if ( $styles =~ /\bSCPZIP_REPLACE\b/ ) # spent 7.55ms making 15895 calls to installer::scpzipfiles::CORE:match, avg 475ns/call |
91 | { | ||||
92 | # Language specific subdirectory | ||||
93 | |||||
94 | my $onelanguage = $onefile->{'specificlanguage'}; | ||||
95 | |||||
96 | if ($onelanguage eq "") | ||||
97 | { | ||||
98 | $onelanguage = "00"; # files without language into directory "00" | ||||
99 | } | ||||
100 | |||||
101 | my $replacedir = $replacedirbase . $installer::globals::separator . $onelanguage . $installer::globals::separator; | ||||
102 | 110 | 76.0ms | installer::systemactions::create_directory($replacedir); # creating language specific directories # spent 76.0ms making 110 calls to installer::systemactions::create_directory, avg 691µs/call | ||
103 | |||||
104 | # copy files and edit them with the variables defined in the zip.lst | ||||
105 | |||||
106 | my $longfilename = 0; | ||||
107 | |||||
108 | my $onefilename = $onefile->{'Name'}; | ||||
109 | my $sourcepath = $onefile->{'sourcepath'}; | ||||
110 | |||||
111 | 220 | 355µs | if ( $onefilename =~ /^\s*\Q$installer::globals::separator\E/ ) # filename begins with a slash, for instance /registry/schema/org/openoffice/VCL.xcs # spent 202µs making 110 calls to installer::scpzipfiles::CORE:regcomp, avg 2µs/call
# spent 153µs making 110 calls to installer::scpzipfiles::CORE:match, avg 1µs/call | ||
112 | { | ||||
113 | $onefilename =~ s/^\s*\Q$installer::globals::separator\E//; | ||||
114 | $longfilename = 1; | ||||
115 | } | ||||
116 | |||||
117 | my $destinationpath = $replacedir . $onefilename; | ||||
118 | my $movepath = $destinationpath . ".orig"; | ||||
119 | |||||
120 | if ( $longfilename ) # the destination directory has to be created before copying | ||||
121 | { | ||||
122 | my $destdir = $movepath; | ||||
123 | installer::pathanalyzer::get_path_from_fullqualifiedname(\$destdir); | ||||
124 | installer::systemactions::create_directory_structure($destdir); | ||||
125 | } | ||||
126 | |||||
127 | 110 | 252ms | my $copysuccess = installer::systemactions::copy_one_file($sourcepath, $movepath); # spent 252ms making 110 calls to installer::systemactions::copy_one_file, avg 2.29ms/call | ||
128 | |||||
129 | 330 | 10.5ms | if ( $copysuccess ) | ||
130 | { | ||||
131 | # Now the file can be edited | ||||
132 | # ToDo: How about binary patching? | ||||
133 | |||||
134 | 110 | 148ms | my $onefileref = installer::files::read_file($movepath); # spent 148ms making 110 calls to installer::files::read_file, avg 1.35ms/call | ||
135 | 110 | 167ms | replace_all_ziplistvariables_in_file($onefileref, $variableshashref); # spent 167ms making 110 calls to installer::scpzipfiles::replace_all_ziplistvariables_in_file, avg 1.52ms/call | ||
136 | 110 | 90.3ms | installer::files::save_file($destinationpath ,$onefileref); # spent 90.3ms making 110 calls to installer::files::save_file, avg 821µs/call | ||
137 | } | ||||
138 | |||||
139 | # Saving the original source, where the file was found | ||||
140 | $onefile->{'originalsourcepath'} = $onefile->{'sourcepath'}; | ||||
141 | |||||
142 | # Writing the new sourcepath into the hashref, even if it was no copied | ||||
143 | |||||
144 | $onefile->{'sourcepath'} = $destinationpath; | ||||
145 | } | ||||
146 | } | ||||
147 | |||||
148 | my $infoline = "\n"; | ||||
149 | push( @installer::globals::logfileinfo, $infoline); | ||||
150 | } | ||||
151 | |||||
152 | 1 | 8µs | 1; | ||
# spent 7.71ms within installer::scpzipfiles::CORE:match which was called 16005 times, avg 481ns/call:
# 15895 times (7.55ms+0s) by installer::scpzipfiles::resolving_scpzip_replace_flag at line 90, avg 475ns/call
# 110 times (153µs+0s) by installer::scpzipfiles::resolving_scpzip_replace_flag at line 111, avg 1µs/call | |||||
# spent 202µs within installer::scpzipfiles::CORE:regcomp which was called 110 times, avg 2µs/call:
# 110 times (202µs+0s) by installer::scpzipfiles::resolving_scpzip_replace_flag at line 111, avg 2µs/call | |||||
# spent 154ms within installer::scpzipfiles::CORE:subst which was called 283508 times, avg 544ns/call:
# 283508 times (154ms+0s) by installer::scpzipfiles::replace_all_ziplistvariables_in_file at line 46, avg 544ns/call | |||||
# spent 25.7ms within installer::scpzipfiles::CORE:substcont which was called 9109 times, avg 3µs/call:
# 9109 times (25.7ms+0s) by installer::scpzipfiles::replace_all_ziplistvariables_in_file at line 46, avg 3µs/call |