PHP: Avoid calling is_resource() twice with no good reason
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11466 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
0d539c8048
commit
22351914fe
1 changed files with 4 additions and 2 deletions
|
|
@ -1633,8 +1633,10 @@ public:
|
||||||
* _p_Foo -> Foo, _p_ns__Bar -> Bar
|
* _p_Foo -> Foo, _p_ns__Bar -> Bar
|
||||||
* TODO: do this in a more elegant way
|
* TODO: do this in a more elegant way
|
||||||
*/
|
*/
|
||||||
Printf(output, "\t\tif (is_resource($r)) $class='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix);
|
Printf(output, "\t\tif (is_resource($r)) {\n");
|
||||||
Printf(output, "\t\treturn is_resource($r) ? new $class($r) : $r;\n");
|
Printf(output, "\t\t\t$class='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix);
|
||||||
|
Printf(output, "\t\t\treturn new $class($r);\n\t\t}\n");
|
||||||
|
Printf(output, "\t\telse return $r;\n");
|
||||||
} else {
|
} else {
|
||||||
Printf(output, "\t\t$this->%s = $r;\n", SWIG_PTR);
|
Printf(output, "\t\t$this->%s = $r;\n", SWIG_PTR);
|
||||||
Printf(output, "\t\treturn $this;\n");
|
Printf(output, "\t\treturn $this;\n");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue