From c80fbb338443a49a4a1b217be5e9c37b6bddb240 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 29 Jul 2009 13:01:07 +0200 Subject: [PATCH] PHP: Avoid calling is_resource() twice with no good reason --- Source/Modules/php.cxx | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 0780064..c14400f 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -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"); -- 1.6.3.3