diff options
author | Pavlo Yatsukhnenko <yatsukhnenko@gmail.com> | 2016-11-21 14:32:53 +0300 |
---|---|---|
committer | Pavlo Yatsukhnenko <yatsukhnenko@gmail.com> | 2016-11-21 18:46:58 +0300 |
commit | 433caf478854efcd17a3bd39e3b8685e0a320572 (patch) | |
tree | bba75e03a142f1123b80467306652cea21dea7ac /redis_array.c | |
parent | 0c351f5d1c5a458492efa906ec1ca02bbbb527a8 (diff) |
refactoring
Diffstat (limited to 'redis_array.c')
-rw-r--r-- | redis_array.c | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/redis_array.c b/redis_array.c index 62a9e246..11bef6ca 100644 --- a/redis_array.c +++ b/redis_array.c @@ -229,9 +229,6 @@ PHP_METHOD(RedisArray, __construct) ZVAL_NULL(&z_dist); /* extract options */ if(z_opts) { - zval *z_retry_interval_p; - zval *z_connect_timeout_p; - hOpts = Z_ARRVAL_P(z_opts); /* extract previous ring. */ @@ -268,15 +265,13 @@ PHP_METHOD(RedisArray, __construct) } /* extract retry_interval option. */ - if ((z_retry_interval_p = zend_hash_str_find(hOpts, "retry_interval", sizeof("retry_interval") - 1)) != NULL) { - if (Z_TYPE_P(z_retry_interval_p) == IS_LONG || Z_TYPE_P(z_retry_interval_p) == IS_STRING) { - if (Z_TYPE_P(z_retry_interval_p) == IS_LONG) { - l_retry_interval = Z_LVAL_P(z_retry_interval_p); - } else { - l_retry_interval = atol(Z_STRVAL_P(z_retry_interval_p)); - } - } - } + if ((zpData = zend_hash_str_find(hOpts, "retry_interval", sizeof("retry_interval") - 1)) != NULL) { + if (Z_TYPE_P(zpData) == IS_LONG) { + l_retry_interval = Z_LVAL_P(zpData); + } else if (Z_TYPE_P(zpData) == IS_STRING) { + l_retry_interval = atol(Z_STRVAL_P(zpData)); + } + } /* extract lazy connect option. */ if ((zpData = zend_hash_str_find(hOpts, "lazy_connect", sizeof("lazy_connect") - 1)) != NULL) { @@ -284,20 +279,15 @@ PHP_METHOD(RedisArray, __construct) } /* extract connect_timeout option */ - if ((z_connect_timeout_p = zend_hash_str_find(hOpts, "connect_timeout", sizeof("connect_timeout") - 1)) != NULL) { - if (Z_TYPE_P(z_connect_timeout_p) == IS_DOUBLE || - Z_TYPE_P(z_connect_timeout_p) == IS_STRING || - Z_TYPE_P(z_connect_timeout_p) == IS_LONG - ) { - if (Z_TYPE_P(z_connect_timeout_p) == IS_DOUBLE) { - d_connect_timeout = Z_DVAL_P(z_connect_timeout_p); - } else if (Z_TYPE_P(z_connect_timeout_p) == IS_LONG) { - d_connect_timeout = Z_LVAL_P(z_connect_timeout_p); - } else { - d_connect_timeout = atof(Z_STRVAL_P(z_connect_timeout_p)); - } - } - } + if ((zpData = zend_hash_str_find(hOpts, "connect_timeout", sizeof("connect_timeout") - 1)) != NULL) { + if (Z_TYPE_P(zpData) == IS_DOUBLE) { + d_connect_timeout = Z_DVAL_P(zpData); + } else if (Z_TYPE_P(zpData) == IS_LONG) { + d_connect_timeout = Z_LVAL_P(zpData); + } else if (Z_TYPE_P(zpData) == IS_STRING) { + d_connect_timeout = atof(Z_STRVAL_P(zpData)); + } + } } /* extract either name of list of hosts from z0 */ |