From f6d785fad2e4824cd82208239ce77ee19068f36a Mon Sep 17 00:00:00 2001 From: skeeter Date: Mon, 27 Aug 2001 03:09:14 +0000 Subject: [PATCH] Small speed enhancement to the code for build_resp(). --- phpgwapi/inc/class.xmlrpc_server.inc.php | 53 +++++++++--------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/phpgwapi/inc/class.xmlrpc_server.inc.php b/phpgwapi/inc/class.xmlrpc_server.inc.php index f56a79e9f0..b14386c449 100644 --- a/phpgwapi/inc/class.xmlrpc_server.inc.php +++ b/phpgwapi/inc/class.xmlrpc_server.inc.php @@ -173,39 +173,26 @@ function build_resp($_res,$recursed=False) { - switch(gettype($_res)) + if(is_array($_res)) { - case 'array': - @reset($_res); - $ele = array(); - while(list($key,$val) = @each($_res)) - { - $ele[$key] = $this->build_resp($val,True); - } - $this->resp_struct[] = CreateObject('phpgwapi.xmlrpcval',$ele,'struct'); - break; - case 'string': - if($recursed) - { - return CreateObject('phpgwapi.xmlrpcval',$_res,'string'); - } - else - { - $this->resp_struct[] = CreateObject('phpgwapi.xmlrpcval',$_res,'string'); - } - break; - case 'integer': - if($recursed) - { - return CreateObject('phpgwapi.xmlrpcval',$_res,'int'); - } - else - { - $this->resp_struct[] = CreateObject('phpgwapi.xmlrpcval',$_res,'int'); - } - break; - default: - break; + @reset($_res); + while(list($key,$val) = @each($_res)) + { + $ele[$key] = $this->build_resp($val,True); + } + $this->resp_struct[] = CreateObject('phpgwapi.xmlrpcval',$ele,'struct'); + } + else + { + $_type = (is_long($_res)?'int':gettype($_res)); + if($recursed) + { + return CreateObject('phpgwapi.xmlrpcval',$_res,$_type); + } + else + { + $this->resp_struct[] = CreateObject('phpgwapi.xmlrpcval',$_res,$_type); + } } } @@ -324,7 +311,7 @@ $this->resp_struct = array(); $this->build_resp($res); /*_debug_array($this->resp_struct); */ - + @reset($this->resp_struct); $r = CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval',$this->resp_struct,'struct')); /* _debug_array($r); */ }