Skip to content

Commit

Permalink
Optim : 'if' statement with common parts
Browse files Browse the repository at this point in the history
  • Loading branch information
s-renier-taonix-fr authored and f3l1x committed Feb 13, 2023
1 parent e8736c0 commit 7f9b8c2
Showing 1 changed file with 24 additions and 47 deletions.
71 changes: 24 additions & 47 deletions src/nusoap.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,18 +478,16 @@ function serialize_val($val, $name = false, $type = false, $name_ns = false, $ty
if ($use == 'literal') {
// TODO: depends on minOccurs
$xml = "<$name$xmlns$atts/>";
$this->debug("serialize_val returning $xml");
return $xml;
} else {
if (isset($type) && isset($type_prefix)) {
$type_str = " xsi:type=\"$type_prefix:$type\"";
} else {
$type_str = '';
}
$xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>";
$this->debug("serialize_val returning $xml");
return $xml;
}
$this->debug("serialize_val returning $xml");
return $xml;
}
// serialize if an xsd built-in primitive type
if ($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])) {
Expand All @@ -505,13 +503,11 @@ function serialize_val($val, $name = false, $type = false, $name_ns = false, $ty
}
if ($use == 'literal') {
$xml = "<$name$xmlns$atts>$val</$name>";
$this->debug("serialize_val returning $xml");
return $xml;
} else {
$xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>";
$this->debug("serialize_val returning $xml");
return $xml;
}
$this->debug("serialize_val returning $xml");
return $xml;
}
// detect type and serialize
$xml = '';
Expand Down Expand Up @@ -777,10 +773,8 @@ function contractQname($qname)
if ($p) {
return $p . ':' . $name;
}
return $qname;
} else {
return $qname;
}
return $qname;
}

/**
Expand Down Expand Up @@ -1432,41 +1426,26 @@ function schemaStartElement($parser, $name, $attrs)
$this->xdebug('processing named complexType ' . $attrs['name']);
//$this->currentElement = false;
$this->currentComplexType = $attrs['name'];
$this->complexTypes[$this->currentComplexType] = $attrs;
$this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
// This is for constructs like
// <complexType name="ListOfString" base="soap:Array">
// <sequence>
// <element name="string" type="xsd:string"
// minOccurs="0" maxOccurs="unbounded" />
// </sequence>
// </complexType>
if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) {
$this->xdebug('complexType is unusual array');
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
} else {
$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
}
} else {
$name = $this->CreateTypeName($this->currentElement);
$this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name);
$this->currentComplexType = $name;
//$this->currentElement = false;
$this->complexTypes[$this->currentComplexType] = $attrs;
$this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
// This is for constructs like
// <complexType name="ListOfString" base="soap:Array">
// <sequence>
// <element name="string" type="xsd:string"
// minOccurs="0" maxOccurs="unbounded" />
// </sequence>
// </complexType>
if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) {
$this->xdebug('complexType is unusual array');
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
} else {
$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
}
}
$this->complexTypes[$this->currentComplexType] = $attrs;
$this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
// This is for constructs like
// <complexType name="ListOfString" base="soap:Array">
// <sequence>
// <element name="string" type="xsd:string"
// minOccurs="0" maxOccurs="unbounded" />
// </sequence>
// </complexType>
if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) {
$this->xdebug('complexType is unusual array');
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
} else {
$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
}
$this->complexTypes[$this->currentComplexType]['simpleContent'] = 'false';
break;
Expand Down Expand Up @@ -7417,7 +7396,6 @@ function buildVal($pos)
$ret = is_array($params) ? $params : array();
$this->debug('in buildVal, return:');
$this->appendDebug($this->varDump($ret));
return $ret;
} else {
$this->debug('in buildVal, no children, building scalar');
$cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : '';
Expand All @@ -7434,8 +7412,9 @@ function buildVal($pos)
}
$ret = $this->message[$pos]['cdata'];
$this->debug("in buildVal, return: $ret");
return $ret;
}

return $ret;
}
}

Expand Down Expand Up @@ -8243,10 +8222,10 @@ function _getProxyClassCode($r)
$evalStr = '';
foreach ($this->operations as $operation => $opData) {
if ($operation != '') {
$paramStr = '';
$paramArrayStr = '';
// create param string and param comment string
if (sizeof($opData['input']['parts']) > 0) {
$paramStr = '';
$paramArrayStr = '';
$paramCommentStr = '';
foreach ($opData['input']['parts'] as $name => $type) {
$paramStr .= "\$$name, ";
Expand All @@ -8257,8 +8236,6 @@ function _getProxyClassCode($r)
$paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr) - 2);
$paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr) - 2);
} else {
$paramStr = '';
$paramArrayStr = '';
$paramCommentStr = 'void';
}
$opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace'];
Expand Down

0 comments on commit 7f9b8c2

Please sign in to comment.