summaryrefslogtreecommitdiff
path: root/ext/com_dotnet/com_com.c
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2004-01-13 13:38:11 +0000
committerWez Furlong <wez@php.net>2004-01-13 13:38:11 +0000
commit4573a562a3df747cfe06d2a3eea98d5f5f155e92 (patch)
tree0fc2222f1c4c2dc93599b840bcd0ce3e11e19823 /ext/com_dotnet/com_com.c
parent5ebcab9da33899b643a54c5fe04db24c9bcd671e (diff)
downloadphp-git-4573a562a3df747cfe06d2a3eea98d5f5f155e92.tar.gz
Fix leaking constructors.
Implement a cache for method signatures and DISPID's to greatly improve performance when repeatedly accessing members with the same names.
Diffstat (limited to 'ext/com_dotnet/com_com.c')
-rw-r--r--ext/com_dotnet/com_com.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c
index 135d1c98ba..b63458481f 100644
--- a/ext/com_dotnet/com_com.c
+++ b/ext/com_dotnet/com_com.c
@@ -355,7 +355,17 @@ HRESULT php_com_get_id_of_name(php_com_dotnet_object *obj, char *name,
{
OLECHAR *olename;
HRESULT hr;
+ DISPID *dispid_ptr;
+ if (namelen == -1) {
+ namelen = strlen(name);
+ }
+
+ if (obj->id_of_name_cache && SUCCESS == zend_hash_find(obj->id_of_name_cache, name, namelen, (void**)&dispid_ptr)) {
+ *dispid = *dispid_ptr;
+ return S_OK;
+ }
+
olename = php_com_string_to_olestring(name, namelen, obj->code_page TSRMLS_CC);
if (obj->typeinfo) {
@@ -373,6 +383,15 @@ HRESULT php_com_get_id_of_name(php_com_dotnet_object *obj, char *name,
}
efree(olename);
+ if (SUCCEEDED(hr)) {
+ /* cache the mapping */
+ if (!obj->id_of_name_cache) {
+ ALLOC_HASHTABLE(obj->id_of_name_cache);
+ zend_hash_init(obj->id_of_name_cache, 2, NULL, NULL, 0);
+ }
+ zend_hash_update(obj->id_of_name_cache, name, namelen, dispid, sizeof(*dispid), NULL);
+ }
+
return hr;
}
@@ -388,7 +407,7 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, char *name, int namelen,
zend_internal_function *f = (zend_internal_function*)EG(function_state_ptr)->function;
/* assumption: that the active function (f) is the function we generated for the engine */
- if (!f || f->type != ZEND_OVERLOADED_FUNCTION_TEMPORARY || f->arg_info == NULL) {
+ if (!f || f->arg_info == NULL) {
f = NULL;
}