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:
Miklos Vajna 2009-07-29 11:03:22 +00:00
commit 22351914fe

View file

@ -1633,8 +1633,10 @@ public:
* _p_Foo -> Foo, _p_ns__Bar -> Bar
* 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\treturn is_resource($r) ? new $class($r) : $r;\n");
Printf(output, "\t\tif (is_resource($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 {
Printf(output, "\t\t$this->%s = $r;\n", SWIG_PTR);
Printf(output, "\t\treturn $this;\n");