commit:     5230ffbdf53c228672e4a223d9c51d7a0fd63937
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Tue Jan  6 03:21:28 2026 +0000
Commit:     Kerin Millar <kfm <AT> plushkava <DOT> net>
CommitDate: Tue Jan  6 03:21:57 2026 +0000
URL:        https://gitweb.gentoo.org/proj/locale-gen.git/commit/?id=5230ffbd

Use grep() to eliminate duplicate/already-installed locales

For those that find the above confusing, grep() is to Perl as filter()
is to various other languages.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>

 locale-gen | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/locale-gen b/locale-gen
index ed1f0e1..60a15fe 100644
--- a/locale-gen
+++ b/locale-gen
@@ -89,17 +89,14 @@ umask 0022;
        }
 
        # Filter out locales that are duplicates or that are already installed.
-       my %requested_by;
-       my $i = 0;
-       while ($i <= $#locales) {
-               my $canonical = $locales[$i][2];
-               my $normal = normalize($canonical);
-               if ($requested_by{$normal}++ || $installed_by{$normal}) {
-                       splice @locales, $i, 1;
-               } else {
-                       ++$i;
-               }
-       }
+       @locales = do {
+               my %requested_by;
+               grep {
+                       my $canonical = $_->[2];
+                       my $normal = normalize($canonical);
+                       ! $requested_by{$normal}++ && ! $installed_by{$normal};
+               } @locales;
+       };
 
        # If a non-actionable update was requested, proceed no further.
        if (! @locales) {

Reply via email to