Skip to content

Commit 4376204

Browse files
committed
Use interned strings in cache info (partially)
Only for the elements themselves.
1 parent 8df5bde commit 4376204

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

apc_cache.c

+20-17
Original file line numberDiff line numberDiff line change
@@ -997,23 +997,32 @@ static void apc_cache_init_entry(
997997
}
998998
/* }}} */
999999

1000+
static inline void array_add_long(zval *array, zend_string *key, zend_long lval) {
1001+
zval zv;
1002+
ZVAL_LONG(&zv, lval);
1003+
zend_hash_add_new(Z_ARRVAL_P(array), key, &zv);
1004+
}
1005+
10001006
/* {{{ apc_cache_link_info */
10011007
static zval apc_cache_link_info(apc_cache_t *cache, apc_cache_entry_t *p)
10021008
{
1003-
zval link;
1004-
1009+
zval link, zv;
10051010
array_init(&link);
10061011

1007-
add_assoc_str(&link, "info", zend_string_dup(p->key, 0));
1008-
add_assoc_long(&link, "ttl", p->ttl);
1012+
ZVAL_STR(&zv, zend_string_dup(p->key, 0));
1013+
zend_hash_add_new(Z_ARRVAL(link), apc_str_info, &zv);
1014+
1015+
array_add_long(&link, apc_str_ttl, p->ttl);
10091016

1010-
add_assoc_double(&link, "num_hits", (double)p->nhits);
1011-
add_assoc_long(&link, "mtime", p->mtime);
1012-
add_assoc_long(&link, "creation_time", p->ctime);
1013-
add_assoc_long(&link, "deletion_time", p->dtime);
1014-
add_assoc_long(&link, "access_time", p->atime);
1015-
add_assoc_long(&link, "ref_count", p->ref_count);
1016-
add_assoc_long(&link, "mem_size", p->mem_size);
1017+
ZVAL_DOUBLE(&zv, (double) p->nhits);
1018+
zend_hash_add_new(Z_ARRVAL(link), apc_str_num_hits, &zv);
1019+
1020+
array_add_long(&link, apc_str_mtime, p->mtime);
1021+
array_add_long(&link, apc_str_creation_time, p->ctime);
1022+
array_add_long(&link, apc_str_deletion_time, p->dtime);
1023+
array_add_long(&link, apc_str_access_time, p->atime);
1024+
array_add_long(&link, apc_str_ref_count, p->ref_count);
1025+
array_add_long(&link, apc_str_mem_size, p->mem_size);
10171026

10181027
return link;
10191028
}
@@ -1090,12 +1099,6 @@ PHP_APCU_API zend_bool apc_cache_info(zval *info, apc_cache_t *cache, zend_bool
10901099
}
10911100
/* }}} */
10921101

1093-
static inline void array_add_long(zval *array, zend_string *key, zend_long lval) {
1094-
zval zv;
1095-
ZVAL_LONG(&zv, lval);
1096-
zend_hash_add_new(Z_ARRVAL_P(array), key, &zv);
1097-
}
1098-
10991102
/*
11001103
fetches information about the key provided
11011104
*/

apc_strings.h

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
X(creation_time) \
2525
X(deletion_time) \
2626
X(hits) \
27+
X(info) \
2728
X(key) \
2829
X(mem_size) \
2930
X(mtime) \

0 commit comments

Comments
 (0)