tony2001                Mon Jul 14 08:08:39 2008 UTC

  Modified files:              
    /php-src/ext/spl    spl_fixedarray.c 
  Log:
  minor speedup - convert offset to long only when needed
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_fixedarray.c?r1=1.3&r2=1.4&diff_format=u
Index: php-src/ext/spl/spl_fixedarray.c
diff -u php-src/ext/spl/spl_fixedarray.c:1.3 
php-src/ext/spl/spl_fixedarray.c:1.4
--- php-src/ext/spl/spl_fixedarray.c:1.3        Sun Jul 13 15:59:38 2008
+++ php-src/ext/spl/spl_fixedarray.c    Mon Jul 14 08:08:39 2008
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: spl_fixedarray.c,v 1.3 2008/07/13 15:59:38 colder Exp $ */
+/* $Id: spl_fixedarray.c,v 1.4 2008/07/14 08:08:39 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -317,7 +317,11 @@
                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 @@
                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 @@
 {
        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 @@
        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;
@@ -675,6 +691,7 @@
        intern = (spl_fixedarray_object 
*)zend_object_store_get_object(return_value TSRMLS_CC);
        intern->array = array;
 }
+/* }}} */
 
 /* {{{ proto int SplFixedArray::getSize(void)
 */



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to