@@ -103,6 +103,13 @@ void redis_register_persistent_resource(zend_string *id, void *ptr, int le_id) {
103
103
zend_register_persistent_resource (ZSTR_VAL (id ), ZSTR_LEN (id ), ptr , le_id );
104
104
}
105
105
106
+ /* Do not allocate empty string or string with one character */
107
+ static zend_always_inline void redis_add_next_index_stringl (zval * arg , const char * str , size_t length ) {
108
+ zval tmp ;
109
+ ZVAL_STRINGL_FAST (& tmp , str , length );
110
+ zend_hash_next_index_insert (Z_ARRVAL_P (arg ), & tmp );
111
+ }
112
+
106
113
static ConnectionPool *
107
114
redis_sock_get_connection_pool (RedisSock * redis_sock )
108
115
{
@@ -2666,14 +2673,14 @@ PHP_REDIS_API int redis_string_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock
2666
2673
}
2667
2674
if (IS_ATOMIC (redis_sock )) {
2668
2675
if (!redis_unpack (redis_sock , response , response_len , return_value )) {
2669
- RETVAL_STRINGL (response , response_len );
2676
+ RETVAL_STRINGL_FAST (response , response_len );
2670
2677
}
2671
2678
} else {
2672
2679
zval z_unpacked ;
2673
2680
if (redis_unpack (redis_sock , response , response_len , & z_unpacked )) {
2674
2681
add_next_index_zval (z_tab , & z_unpacked );
2675
2682
} else {
2676
- add_next_index_stringl (z_tab , response , response_len );
2683
+ redis_add_next_index_stringl (z_tab , response , response_len );
2677
2684
}
2678
2685
}
2679
2686
@@ -3460,7 +3467,7 @@ redis_mbulk_reply_loop(RedisSock *redis_sock, zval *z_tab, int count,
3460
3467
if (unwrap && redis_unpack (redis_sock , line , len , & z_unpacked )) {
3461
3468
add_next_index_zval (z_tab , & z_unpacked );
3462
3469
} else {
3463
- add_next_index_stringl (z_tab , line , len );
3470
+ redis_add_next_index_stringl (z_tab , line , len );
3464
3471
}
3465
3472
efree (line );
3466
3473
}
@@ -3882,7 +3889,7 @@ redis_unpack(RedisSock *redis_sock, const char *src, int srclen, zval *zdst) {
3882
3889
/* Uncompress, then unserialize */
3883
3890
if (redis_uncompress (redis_sock , & buf , & len , src , srclen )) {
3884
3891
if (!redis_unserialize (redis_sock , buf , len , zdst )) {
3885
- ZVAL_STRINGL (zdst , buf , len );
3892
+ ZVAL_STRINGL_FAST (zdst , buf , len );
3886
3893
}
3887
3894
efree (buf );
3888
3895
return 1 ;
0 commit comments