aboutsummaryrefslogtreecommitdiffstats
path: root/Bugzilla/WebService/Server
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2013-07-29 12:35:28 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2013-07-29 12:35:28 +0200
commit6fd9f0a35c71219124f972afecc2c41ad047f660 (patch)
tree5045af99c9244b0538a4bc6046727cdb8b538c17 /Bugzilla/WebService/Server
parent14158faf6612b3b6aff191597c34bff6798230df (diff)
downloadbugs-6fd9f0a35c71219124f972afecc2c41ad047f660.tar
bugs-6fd9f0a35c71219124f972afecc2c41ad047f660.tar.gz
bugs-6fd9f0a35c71219124f972afecc2c41ad047f660.tar.bz2
bugs-6fd9f0a35c71219124f972afecc2c41ad047f660.tar.xz
bugs-6fd9f0a35c71219124f972afecc2c41ad047f660.zip
Bug 897003: Improve _strip_undefs() performance
r/a=sgreen
Diffstat (limited to 'Bugzilla/WebService/Server')
-rw-r--r--Bugzilla/WebService/Server/XMLRPC.pm17
1 files changed, 9 insertions, 8 deletions
diff --git a/Bugzilla/WebService/Server/XMLRPC.pm b/Bugzilla/WebService/Server/XMLRPC.pm
index eab718efc..93c9b4cdc 100644
--- a/Bugzilla/WebService/Server/XMLRPC.pm
+++ b/Bugzilla/WebService/Server/XMLRPC.pm
@@ -211,7 +211,7 @@ package Bugzilla::XMLRPC::Serializer;
use 5.10.1;
use strict;
-use Scalar::Util qw(blessed);
+use Scalar::Util qw(blessed reftype);
# We can't use "use parent" because XMLRPC::Serializer doesn't return
# a true value.
use XMLRPC::Lite;
@@ -245,8 +245,8 @@ sub envelope {
my $self = shift;
my ($type, $method, $data) = @_;
# If the type isn't a successful response we don't want to change the values.
- if ($type eq 'response'){
- $data = _strip_undefs($data);
+ if ($type eq 'response') {
+ _strip_undefs($data);
}
return $self->SUPER::envelope($type, $method, $data);
}
@@ -257,7 +257,9 @@ sub envelope {
# so it cannot be recursed like the other hash type objects.
sub _strip_undefs {
my ($initial) = @_;
- if (ref $initial eq "HASH" || (blessed $initial && $initial->isa("HASH"))) {
+ my $type = reftype($initial) or return;
+
+ if ($type eq "HASH") {
while (my ($key, $value) = each(%$initial)) {
if ( !defined $value
|| (blessed $value && $value->isa('XMLRPC::Data') && !defined $value->value) )
@@ -266,11 +268,11 @@ sub _strip_undefs {
delete $initial->{$key};
}
else {
- $initial->{$key} = _strip_undefs($value);
+ _strip_undefs($value);
}
}
}
- if (ref $initial eq "ARRAY" || (blessed $initial && $initial->isa("ARRAY"))) {
+ elsif ($type eq "ARRAY") {
for (my $count = 0; $count < scalar @{$initial}; $count++) {
my $value = $initial->[$count];
if ( !defined $value
@@ -281,11 +283,10 @@ sub _strip_undefs {
$count--;
}
else {
- $initial->[$count] = _strip_undefs($value);
+ _strip_undefs($value);
}
}
}
- return $initial;
}
sub BEGIN {