From: Michael Wallner Date: Fri, 23 Feb 2007 20:38:34 +0000 (+0000) Subject: - fix regressin X-Git-Tag: RELEASE_1_5_2~2 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=commitdiff_plain;h=19511041421e17223c6208d84e39333c62c95041 - fix regressin - optimize string cmp --- diff --git a/http_request_object.c b/http_request_object.c index 0c65812..7f427b8 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -888,34 +888,34 @@ PHP_METHOD(HttpRequest, setOptions) RETURN_TRUE; } - old_opts = zend_read_property(THIS_CE, getThis(), ZEND_STRS("options")-1, 0 TSRMLS_CC); - MAKE_STD_ZVAL(add_opts); array_init(add_opts); /* some options need extra attention -- thus cannot use array_merge() directly */ FOREACH_KEYVAL(pos, opts, key, opt) { if (key.type == HASH_KEY_IS_STRING) { - if (!strcmp(key.str, "headers")) { +#define KEYMATCH(k, s) ((sizeof(s)==k.len) && !strcasecmp(k.str, s)) + if (KEYMATCH(key, "headers")) { zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "addheaders", NULL, *opt); - } else if (!strcmp(key.str, "cookies")) { + } else if (KEYMATCH(key, "cookies")) { zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "addcookies", NULL, *opt); - } else if (!strcmp(key.str, "ssl")) { + } else if (KEYMATCH(key, "ssl")) { zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "addssloptions", NULL, *opt); - } else if ((!strcasecmp(key.str, "url")) || (!strcasecmp(key.str, "uri"))) { + } else if (KEYMATCH(key, "url") || KEYMATCH(key, "uri")) { zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "seturl", NULL, *opt); - } else if (!strcmp(key.str, "method")) { + } else if (KEYMATCH(key, "method")) { zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "setmethod", NULL, *opt); #if HTTP_CURL_VERSION(7,14,1) - } else if (!strcmp(key.str, "resetcookies")) { + } else if (KEYMATCH(key, "resetcookies")) { getObject(http_request_object, obj); http_request_reset_cookies(obj->request, 0); #endif - } else if (!strcmp(key.str, "enablecookies")) { + } else if (KEYMATCH(key, "enablecookies")) { getObject(http_request_object, obj); http_request_enable_cookies(obj->request); - } else if (!strcasecmp(key.str, "recordHistory")) { + } else if (KEYMATCH(key, "recordHistory")) { zend_update_property_bool(THIS_CE, getThis(), ZEND_STRS("recordHistory")-1, 1 TSRMLS_CC); } else if (Z_TYPE_PP(opt) == IS_NULL) { + old_opts = zend_read_property(THIS_CE, getThis(), ZEND_STRS("options")-1, 0 TSRMLS_CC); if (Z_TYPE_P(old_opts) == IS_ARRAY) { zend_hash_del(Z_ARRVAL_P(old_opts), key.str, key.len); } @@ -926,6 +926,7 @@ PHP_METHOD(HttpRequest, setOptions) } } + old_opts = zend_read_property(THIS_CE, getThis(), ZEND_STRS("options")-1, 0 TSRMLS_CC); if (Z_TYPE_P(old_opts) == IS_ARRAY) { array_copy(Z_ARRVAL_P(old_opts), Z_ARRVAL_P(new_opts)); }