@@ -1044,18 +1044,17 @@ int redis_cmd_append_sstr(smart_string *str, char *append, int append_len) {
1044
1044
* Append an integer to a smart string command
1045
1045
*/
1046
1046
int redis_cmd_append_sstr_int (smart_string * str , int append ) {
1047
- char int_buf [32 ];
1048
- int int_len = snprintf (int_buf , sizeof (int_buf ), "%d" , append );
1049
- return redis_cmd_append_sstr (str , int_buf , int_len );
1047
+ return redis_cmd_append_sstr_long (str , (long ) append );
1050
1048
}
1051
1049
1052
1050
/*
1053
1051
* Append a long to a smart string command
1054
1052
*/
1055
1053
int redis_cmd_append_sstr_long (smart_string * str , long append ) {
1056
1054
char long_buf [32 ];
1057
- int long_len = snprintf (long_buf , sizeof (long_buf ), "%ld" , append );
1058
- return redis_cmd_append_sstr (str , long_buf , long_len );
1055
+ char * result = zend_print_long_to_buf (long_buf + sizeof (long_buf ) - 1 , append );
1056
+ int int_len = long_buf + sizeof (long_buf ) - 1 - result ;
1057
+ return redis_cmd_append_sstr (str , result , int_len );
1059
1058
}
1060
1059
1061
1060
/*
@@ -3937,10 +3936,15 @@ redis_serialize(RedisSock *redis_sock, zval *z, char **val, size_t *val_len)
3937
3936
break ;
3938
3937
3939
3938
default : { /* copy */
3940
- zend_string * zstr = zval_get_string (z );
3939
+ zend_string * zstr = zval_get_string_func (z );
3940
+ if (ZSTR_IS_INTERNED (zstr )) { // do not reallocate interned strings
3941
+ * val = ZSTR_VAL (zstr );
3942
+ * val_len = ZSTR_LEN (zstr );
3943
+ return 0 ;
3944
+ }
3941
3945
* val = estrndup (ZSTR_VAL (zstr ), ZSTR_LEN (zstr ));
3942
3946
* val_len = ZSTR_LEN (zstr );
3943
- zend_string_release (zstr );
3947
+ zend_string_efree (zstr );
3944
3948
return 1 ;
3945
3949
}
3946
3950
}
0 commit comments