diff options
author | Raphaël Hertzog <hertzog@debian.org> | 2009-11-06 15:07:38 +0100 |
---|---|---|
committer | Raphaël Hertzog <hertzog@debian.org> | 2009-11-06 15:29:53 +0100 |
commit | 0374e5565de9d42768ec8babdaabfb51cec4f6a6 (patch) | |
tree | f1432c38201f6611a5372f0f4db95ab1a70debbf /scripts/Dpkg/Control | |
parent | 0b1d71a6506ae053ca3c6ed06d2e4a0da0052da7 (diff) | |
download | dpkg-0374e5565de9d42768ec8babdaabfb51cec4f6a6.tar.gz |
Dpkg::Control::Hash: use lower-case internally for keys
Only use field_capitalize() when exporting keys names outside of the
object. lc() is way faster than field_capitalize() and that makes
a difference in performance when you're reading/setting values many
times.
Diffstat (limited to 'scripts/Dpkg/Control')
-rw-r--r-- | scripts/Dpkg/Control/Hash.pm | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/scripts/Dpkg/Control/Hash.pm b/scripts/Dpkg/Control/Hash.pm index d2cbe09d1..151722c7d 100644 --- a/scripts/Dpkg/Control/Hash.pm +++ b/scripts/Dpkg/Control/Hash.pm @@ -388,7 +388,7 @@ sub TIEHASH { sub FETCH { my ($self, $key) = @_; - $key = field_capitalize($key); + $key = lc($key); return $self->[0]->{$key} if exists $self->[0]->{$key}; return undef; } @@ -407,16 +407,16 @@ sub STORE { internerr("field %s has trailing newline >%s<", $key, $value); } # Store it - $key = field_capitalize($key); + $key = lc($key); if (not exists $self->[0]->{$key}) { - push @{$$parent->{'in_order'}}, $key; + push @{$$parent->{'in_order'}}, field_capitalize($key); } $self->[0]->{$key} = $value; } sub EXISTS { my ($self, $key) = @_; - $key = field_capitalize($key); + $key = lc($key); return exists $self->[0]->{$key}; } @@ -424,10 +424,10 @@ sub DELETE { my ($self, $key) = @_; my $parent = $self->[1]; my $in_order = $$parent->{'in_order'}; - $key = field_capitalize($key); + $key = lc($key); if (exists $self->[0]->{$key}) { delete $self->[0]->{$key}; - @{$in_order} = grep { $_ ne $key } @{$in_order}; + @$in_order = grep { lc($_) ne $key } @$in_order; return 1; } else { return 0; @@ -438,7 +438,7 @@ sub FIRSTKEY { my $self = shift; my $parent = $self->[1]; foreach (@{$$parent->{'in_order'}}) { - return $_ if exists $self->[0]->{$_}; + return $_ if exists $self->[0]->{lc($_)}; } } @@ -448,7 +448,7 @@ sub NEXTKEY { my $found = 0; foreach (@{$$parent->{'in_order'}}) { if ($found) { - return $_ if exists $self->[0]->{$_}; + return $_ if exists $self->[0]->{lc($_)}; } else { $found = 1 if $_ eq $last; } |