summaryrefslogtreecommitdiffstats
path: root/perl-install/printer/printerdrake.pm
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2003-01-13 09:00:49 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2003-01-13 09:00:49 +0000
commit80ebe4ae36c84e74c2e2d7b58ca8524f0a6205ad (patch)
treed912fa10f87a4cd9ee8775997ca0e6717ce42ff5 /perl-install/printer/printerdrake.pm
parentb63a95340228bcd0eb70eeff5da8c3afe4e4598a (diff)
downloaddrakx-backup-do-not-use-80ebe4ae36c84e74c2e2d7b58ca8524f0a6205ad.tar
drakx-backup-do-not-use-80ebe4ae36c84e74c2e2d7b58ca8524f0a6205ad.tar.gz
drakx-backup-do-not-use-80ebe4ae36c84e74c2e2d7b58ca8524f0a6205ad.tar.bz2
drakx-backup-do-not-use-80ebe4ae36c84e74c2e2d7b58ca8524f0a6205ad.tar.xz
drakx-backup-do-not-use-80ebe4ae36c84e74c2e2d7b58ca8524f0a6205ad.zip
setup_local_autoscan():
- don't reinvent the wheel, reverse is faster - remove doble $device initialization in one path
Diffstat (limited to 'perl-install/printer/printerdrake.pm')
-rw-r--r--perl-install/printer/printerdrake.pm24
1 files changed, 3 insertions, 21 deletions
diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm
index 04464b1bd..bca7ae3ff 100644
--- a/perl-install/printer/printerdrake.pm
+++ b/perl-install/printer/printerdrake.pm
@@ -637,26 +637,14 @@ sub setup_local_autoscan {
$printer->{currentqueue}{connect} =~ m/^file:/) {
# Non-HP or HP print-only device (HPOJ not used)
$device = $printer->{currentqueue}{connect};
- $device =~ s/^file://;
- foreach my $p (keys %{$menuentries}) {
- if ($device eq $menuentries->{$p}) {
- $menuchoice = $p;
- last;
- }
- }
+ $menuchoice = { reverse %$menuentries }->{$device}
} elsif ($printer->{configured}{$queue} &&
$printer->{currentqueue}{connect} =~ m!^ptal:/mlc:!) {
# HP multi-function device (controlled by HPOJ)
my $ptaldevice = $printer->{currentqueue}{connect};
$ptaldevice =~ s!^ptal:/mlc:!!;
if ($ptaldevice =~ /^par:(\d+)$/) {
- $device = "/dev/lp$1";
- foreach my $p (keys %{$menuentries}) {
- if ($device eq $menuentries->{$p}) {
- $menuchoice = $p;
- last;
- }
- }
+ $menuchoice = { reverse %$menuentries }->{"/dev/lp$1"}
} else {
my $make = lc($printer->{currentqueue}{make});
my $model = lc($printer->{currentqueue}{model});
@@ -674,13 +662,7 @@ sub setup_local_autoscan {
} elsif ($printer->{configured}{$queue} &&
$printer->{currentqueue}{connect} =~ m!^(socket|smb):/!) {
# Ethernet-(TCP/Socket)-connected printer or printer on Windows server
- $device = $printer->{currentqueue}{connect};
- foreach my $p (keys %{$menuentries}) {
- if ($device eq $menuentries->{$p}) {
- $menuchoice = $p;
- last;
- }
- }
+ $menuchoice = { reverse %$menuentries }->{$printer->{currentqueue}{connect}}
} else { $device = "" }
if ($menuchoice eq "" && @menuentrieslist > -1) {
$menuchoice = $menuentrieslist[0];