Re: [APC-DEV] IS_INTERNED for apc + zend mixtures
[email protected] (Gopal V) Wed, 27 Jul 2011 14:19:22 -0700
| Newsgroups | php.apc.dev |
|---|---|
| Message-ID | <[email protected]> |
--------------060902070008080005010806
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
On Wednesday 27 July 2011 01:22 PM, Rasmus Lerdorf wrote:
> On 07/27/2011 01:12 PM, Gopal V wrote:
>> We probably need an override for that so that we can nest multiple
>> interned blocks which are non contiguous between different modules.
>
> Gopal, can you come up with a suggested override patch for the engine
> and we'll get it committed before the alpha-3 release next week.
Attached is the patch suggested.
I propose that APC should not modify the CG() variables at all and
should keep the interned string in its own apc globals.
So the future apc_is_interned_string would have a short-cut for
APCSG() and then check in CG() (either via calling the original
function or an explicit check for speed).
Cheers,
Gopal
--------------060902070008080005010806
Content-Type: text/x-patch;
name="zend-is-interned.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="zend-is-interned.patch"
Index: Zend/zend_string.c
===================================================================
--- Zend/zend_string.c (revision 313794)
+++ Zend/zend_string.c (working copy)
@@ -30,10 +30,12 @@
#endif
ZEND_API const char *(*zend_new_interned_string)(const char *str, int len, int free_src TSRMLS_DC);
+ZEND_API zend_bool (*zend_is_interned_string)(const char *str TSRMLS_DC);
ZEND_API void (*zend_interned_strings_snapshot)(TSRMLS_D);
ZEND_API void (*zend_interned_strings_restore)(TSRMLS_D);
static const char *zend_new_interned_string_int(const char *str, int len, int free_src TSRMLS_DC);
+static zend_bool zend_is_interned_string_int(const char *str TSRMLS_DC);
static void zend_interned_strings_snapshot_int(TSRMLS_D);
static void zend_interned_strings_restore_int(TSRMLS_D);
@@ -64,6 +66,7 @@
#endif
zend_new_interned_string = zend_new_interned_string_int;
+ zend_is_interned_string = zend_is_interned_string_int;
zend_interned_strings_snapshot = zend_interned_strings_snapshot_int;
zend_interned_strings_restore = zend_interned_strings_restore_int;
}
@@ -177,6 +180,11 @@
#endif
}
+static zend_bool zend_is_interned_string_int(const char *s TSRMLS_DC)
+{
+ return (((s) >= CG(interned_strings_start)) && ((s) < CG(interned_strings_end)));
+}
+
static void zend_interned_strings_snapshot_int(TSRMLS_D)
{
CG(interned_strings_snapshot_top) = CG(interned_strings_top);
Index: Zend/zend_string.h
===================================================================
--- Zend/zend_string.h (revision 313794)
+++ Zend/zend_string.h (working copy)
@@ -24,6 +24,7 @@
#include "zend.h"
ZEND_API extern const char *(*zend_new_interned_string)(const char *str, int len, int free_src TSRMLS_DC);
+ZEND_API extern zend_bool (*zend_is_interned_string)(const char *str TSRMLS_DC);
ZEND_API extern void (*zend_interned_strings_snapshot)(TSRMLS_D);
ZEND_API extern void (*zend_interned_strings_restore)(TSRMLS_D);
@@ -33,7 +34,7 @@
#ifndef ZTS
#define IS_INTERNED(s) \
- (((s) >= CG(interned_strings_start)) && ((s) < CG(interned_strings_end)))
+ zend_is_interned_string((s) TSRMLS_CC)
#else
--------------060902070008080005010806--