diff options
| author | Sterling Hughes <sterling@php.net> | 2003-06-29 01:49:10 +0000 |
|---|---|---|
| committer | Sterling Hughes <sterling@php.net> | 2003-06-29 01:49:10 +0000 |
| commit | f605f0b708a328a29dac894b25444c3cfb933f2d (patch) | |
| tree | 8399e0b9bb980c6d8db54902280667bf836099f4 /Zend/zend_operators.c | |
| parent | 505fd434acec1b880c9178f6ff7d04bab0034b92 (diff) | |
| download | php-git-f605f0b708a328a29dac894b25444c3cfb933f2d.tar.gz | |
Very simple, but very effective optimization. Provides a signifigant speed
improvement to matches done via '=='. This checks that the lengths of two
strings are equal before performing a memcmp() on them.
Diffstat (limited to 'Zend/zend_operators.c')
| -rw-r--r-- | Zend/zend_operators.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index ed63fa47c1..b47ce9fe52 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1200,7 +1200,11 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) } if (op1->type == IS_STRING && op2->type == IS_STRING) { - zendi_smart_strcmp(result, op1, op2); + if (op1->value.str.len == op2->value.str.len) { + zendi_smart_strcmp(result, op1, op2); + } else { + ZVAL_LONG(result, 1); + } return SUCCESS; } |
