summaryrefslogtreecommitdiff
path: root/Zend/zend_string.h
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2014-04-02 14:34:44 +0400
committerDmitry Stogov <dmitry@zend.com>2014-04-02 14:34:44 +0400
commitd8099d0468426dbee59f540048376653535270ce (patch)
tree133021a1fda6a2453efcd9a279e9b0a55c006396 /Zend/zend_string.h
parent3b25faa4aa844bce12b1cbb3a3938573965df485 (diff)
downloadphp-git-d8099d0468426dbee59f540048376653535270ce.tar.gz
Changed data layout to allow more efficient operations
Diffstat (limited to 'Zend/zend_string.h')
-rw-r--r--Zend/zend_string.h21
1 files changed, 11 insertions, 10 deletions
diff --git a/Zend/zend_string.h b/Zend/zend_string.h
index 3a94ba03e8..0687700be8 100644
--- a/Zend/zend_string.h
+++ b/Zend/zend_string.h
@@ -36,7 +36,7 @@ void zend_interned_strings_dtor(TSRMLS_D);
END_EXTERN_C()
#ifndef ZTS
-# define IS_INTERNED(s) ((s)->gc.u.v.flags & IS_STR_INTERNED)
+# define IS_INTERNED(s) (GC_FLAGS(s) & IS_STR_INTERNED)
#else
# define IS_INTERNED(s) 0
#endif
@@ -72,7 +72,7 @@ static zend_always_inline void zend_str_forget_hash_val(zend_string *s)
static zend_always_inline zend_uint zend_str_refcount(zend_string *s)
{
if (!IS_INTERNED(s)) {
- return s->gc.refcount;
+ return GC_REFCOUNT(s);
}
return 1;
}
@@ -80,7 +80,7 @@ static zend_always_inline zend_uint zend_str_refcount(zend_string *s)
static zend_always_inline zend_uint zend_str_addref(zend_string *s)
{
if (!IS_INTERNED(s)) {
- return ++s->gc.refcount;
+ return ++GC_REFCOUNT(s);
}
return 1;
}
@@ -88,7 +88,7 @@ static zend_always_inline zend_uint zend_str_addref(zend_string *s)
static zend_always_inline zend_uint zend_str_delref(zend_string *s)
{
if (!IS_INTERNED(s)) {
- return --s->gc.refcount;
+ return --GC_REFCOUNT(s);
}
return 1;
}
@@ -97,10 +97,11 @@ static zend_always_inline zend_string *zend_str_alloc(int len, int persistent)
{
zend_string *ret = pemalloc(sizeof(zend_string) + len, persistent);
- ret->gc.refcount = 1;
- ret->gc.u.v.type = IS_STRING;
- ret->gc.u.v.flags = (persistent ? IS_STR_PERSISTENT : 0);
- ret->gc.u.v.gc_info = 0;
+ GC_REFCOUNT(ret) = 1;
+// TODO use one assignment ???
+ GC_TYPE(ret) = IS_STRING;
+ GC_FLAGS(ret) = (persistent ? IS_STR_PERSISTENT : 0);
+ GC_INFO(ret) = 0;
ret->h = 0;
ret->len = len;
return ret;
@@ -155,7 +156,7 @@ static zend_always_inline void zend_str_free(zend_string *s)
{
if (!IS_INTERNED(s)) {
ZEND_ASSERT(STR_REFCOUNT(s) <= 1);
- pefree(s, s->gc.u.v.flags & IS_STR_PERSISTENT);
+ pefree(s, GC_FLAGS(s) & IS_STR_PERSISTENT);
}
}
@@ -163,7 +164,7 @@ static zend_always_inline void zend_str_release(zend_string *s)
{
if (!IS_INTERNED(s)) {
if (STR_DELREF(s) == 0) {
- pefree(s, s->gc.u.v.flags & IS_STR_PERSISTENT);
+ pefree(s, GC_FLAGS(s) & IS_STR_PERSISTENT);
}
}
}