SS>> If you move the additional check (newlen < SS>> SMART_STR_START_SIZE) and preallocation into the if (!(d)->c) SS>> branch, the changes won't affect the common code path.
Ok, I have rewrote the patch, please see in attachment. It got somehow more inflated, but it now has no more than two conditionals in every codepath, as in original one. -- Stanislav Malyshev, Zend Products Engineer [EMAIL PROTECTED] http://www.zend.com/ +972-3-6139665 ext.109
Index: php_smart_str.h =================================================================== RCS file: /repository/php4/ext/standard/php_smart_str.h,v retrieving revision 1.26 diff -u -b -r1.26 php_smart_str.h --- php_smart_str.h 10 Jun 2003 20:03:38 -0000 1.26 +++ php_smart_str.h 18 Jun 2003 14:32:38 -0000 @@ -36,6 +36,10 @@ #define SMART_STR_PREALLOC 128 #endif +#ifndef SMART_STR_START_SIZE +#define SMART_STR_START_SIZE 78 +#endif + #ifdef SMART_STR_USE_REALLOC #define SMART_STR_REALLOC(a,b,c) realloc((a),(b)) #else @@ -44,11 +48,21 @@ #define smart_str_alloc4(d, n, what, newlen) do { \ - if (!(d)->c) (d)->len = (d)->a = 0; \ + if(!(d)->c) { \ + (d)->len = 0; \ + newlen = (n); \ + if(newlen < SMART_STR_START_SIZE) { \ + (d)->a = SMART_STR_START_SIZE; \ + } else { \ + (d)->a = newlen + SMART_STR_PREALLOC; \ + } \ + (d)->c = SMART_STR_REALLOC((d)->c, (d)->a + 1, (what)); \ + } else { \ newlen = (d)->len + (n); \ - if (newlen >= (d)->a) { \ + if(newlen >= (d)->a) { \ (d)->a = newlen + SMART_STR_PREALLOC; \ (d)->c = SMART_STR_REALLOC((d)->c, (d)->a + 1, (what)); \ + } \ } \ } while (0)
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php