Open
Bug 829488
Opened 13 years ago
Updated 12 years ago
Replace substitution with transliteration wherever possible to improve performance
Categories
(Bugzilla :: Bugzilla-General, enhancement)
Bugzilla
Bugzilla-General
Tracking
()
NEW
People
(Reporter: koosha.khajeh, Unassigned)
References
()
Details
(Keywords: perf)
Attachments
(2 files)
Quote from perldoc perlperf:
"Search and replace or tr
If we have a string which needs to be modified, while a regex will
almost always be much more flexible, "tr", an oft underused tool, can
still be a useful."
it also has a benchmark script that produces interesting results. I changed the iteration to run ten times more; i.e. 1E7 instead of 1E6. On my machine the result is
Benchmark: timing 10000000 iterations of sr, tr...
sr: 12 wallclock secs (12.21 usr + 0.01 sys = 12.22 CPU) @ 818330.61/s (n=10000000)
tr: 4 wallclock secs ( 3.99 usr + 0.00 sys = 3.99 CPU) @ 2506265.66/s (n=10000000)
As you see, the difference is really noticeable. We should replace s/// with tr/// wherever possible.
I attach the benchmark script as well as the ack-grep result of files that have s///.
Comment 2•13 years ago
|
||
Are there places in Bugzilla were tr// would be suitable? tr// doesn't support regexps and doesn't play nice with different encodings.
There are some places like:
Bugzilla/Token.pm
170: $token =~ s/\+/-/g;
171: $token =~ s/\//_/g;
Bugzilla/WebService/Server/JSONRPC.pm
93: $name =~ s/-/_/g;
Bugzilla/WebService/Server/XMLRPC.pm
32: $value =~ s/-//g;
buglist.cgi
126: $bug_ids =~ s/[:-]/,/g;
reports.cgi
104: $image_file =~ s/\+/-/g;
105: $image_file =~ s/\//_/g;
and some more. But one needs to be watchful enough to capture all of them and still not make mistake where regexp must be used.
Updated•12 years ago
|
You need to log in
before you can comment on or make changes to this bug.
Description
•