commit: 40b5fb9e12bcb6b5fe1fa9538ebaa62ac7a0bf2c
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Mon Aug 4 15:53:52 2025 +0000
Commit: Kerin Millar <kfm <AT> plushkava <DOT> net>
CommitDate: Mon Aug 4 15:56:27 2025 +0000
URL: https://gitweb.gentoo.org/proj/locale-gen.git/commit/?id=40b5fb9e
Speed up the trim_line sub by approximately 25%
As regards the trim_line subroutine, it is faster to perform two
destructive substitutions in succession. Have it do so.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
locale-gen | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/locale-gen b/locale-gen
index b74d8d9..18e4fa6 100755
--- a/locale-gen
+++ b/locale-gen
@@ -561,7 +561,9 @@ sub throw_child_error ($cmd, $status = $?) {
}
sub trim_line ($line) {
- return $line =~ s/^\h+|\h+$//gr;
+ $line =~ s/^\h+//;
+ $line =~ s/\h+$//;
+ return $line;
}
END {