summaryrefslogtreecommitdiff
path: root/ext/spl/spl_fixedarray.c
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2008-07-14 08:09:09 (GMT)
committerAntony Dovgal <tony2001@php.net>2008-07-14 08:09:09 (GMT)
commitcd408f1235b16de4fc3f3242aeb8fe47c86ba0cb (patch)
treeb571e2b92644e2e80e01dfbdd9739c7e6e607b68 /ext/spl/spl_fixedarray.c
parentbdc0acdd777b9f51121e7f5b7edc846d6a10c39c (diff)
downloadphp-cd408f1235b16de4fc3f3242aeb8fe47c86ba0cb.tar.gz
MFH: minor speedup - convert offset to long only when needed
Diffstat (limited to 'ext/spl/spl_fixedarray.c')
-rw-r--r--ext/spl/spl_fixedarray.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c
index e70b6d4..b15b64c 100644
--- a/ext/spl/spl_fixedarray.c
+++ b/ext/spl/spl_fixedarray.c
@@ -317,7 +317,11 @@ static inline zval **spl_fixedarray_object_read_dimension_helper(spl_fixedarray_
return NULL;
}
- index = spl_offset_convert_to_long(offset TSRMLS_CC);
+ if (Z_TYPE_P(offset) != IS_LONG) {
+ index = spl_offset_convert_to_long(offset TSRMLS_CC);
+ } else {
+ index = Z_LVAL_P(offset);
+ }
if (index < 0 || intern->array == NULL || index >= intern->array->size) {
zend_throw_exception(spl_ce_RuntimeException, "Index invalid or out of range", 0 TSRMLS_CC);
@@ -369,7 +373,11 @@ static inline void spl_fixedarray_object_write_dimension_helper(spl_fixedarray_o
return;
}
- index = spl_offset_convert_to_long(offset TSRMLS_CC);
+ if (Z_TYPE_P(offset) != IS_LONG) {
+ index = spl_offset_convert_to_long(offset TSRMLS_CC);
+ } else {
+ index = Z_LVAL_P(offset);
+ }
if (index < 0 || intern->array == NULL || index >= intern->array->size) {
zend_throw_exception(spl_ce_RuntimeException, "Index invalid or out of range", 0 TSRMLS_CC);
@@ -407,7 +415,11 @@ static inline void spl_fixedarray_object_unset_dimension_helper(spl_fixedarray_o
{
long index;
- index = spl_offset_convert_to_long(offset TSRMLS_CC);
+ if (Z_TYPE_P(offset) != IS_LONG) {
+ index = spl_offset_convert_to_long(offset TSRMLS_CC);
+ } else {
+ index = Z_LVAL_P(offset);
+ }
if (index < 0 || intern->array == NULL || index >= intern->array->size) {
zend_throw_exception(spl_ce_RuntimeException, "Index invalid or out of range", 0 TSRMLS_CC);
@@ -444,7 +456,11 @@ static inline int spl_fixedarray_object_has_dimension_helper(spl_fixedarray_obje
long index;
int retval;
- index = spl_offset_convert_to_long(offset TSRMLS_CC);
+ if (Z_TYPE_P(offset) != IS_LONG) {
+ index = spl_offset_convert_to_long(offset TSRMLS_CC);
+ } else {
+ index = Z_LVAL_P(offset);
+ }
if (index < 0 || intern->array == NULL || index >= intern->array->size) {
retval = 0;