mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Improved performance of unserialize(), original patch by galaxy dot mipt at gmail dot com
This commit is contained in:
parent
1c9e784985
commit
208aa1025d
4 changed files with 662 additions and 319 deletions
2
NEWS
2
NEWS
|
@ -97,6 +97,8 @@
|
|||
. Don't terminate shell on fatal errors.
|
||||
- Improved ext/zlib: re-implemented non-file related functionality. (Mike)
|
||||
- Improved output layer. See README.NEW-OUTPUT-API for internals. (Mike)
|
||||
- Improved the performance of unserialize(). (galaxy dot mipt at gmail dot com,
|
||||
Kalle)
|
||||
|
||||
- Removed legacy features:
|
||||
. allow_call_time_pass_reference. (Pierrick)
|
||||
|
|
|
@ -42,7 +42,9 @@ typedef HashTable* php_serialize_data_t;
|
|||
|
||||
struct php_unserialize_data {
|
||||
void *first;
|
||||
void *last;
|
||||
void *first_dtor;
|
||||
void *last_dtor;
|
||||
};
|
||||
|
||||
typedef struct php_unserialize_data* php_unserialize_data_t;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -33,25 +33,23 @@ typedef struct {
|
|||
|
||||
static inline void var_push(php_unserialize_data_t *var_hashx, zval **rval)
|
||||
{
|
||||
var_entries *var_hash = (*var_hashx)->first, *prev = NULL;
|
||||
var_entries *var_hash = (*var_hashx)->last;
|
||||
#if 0
|
||||
fprintf(stderr, "var_push(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(rval));
|
||||
#endif
|
||||
|
||||
while (var_hash && var_hash->used_slots == VAR_ENTRIES_MAX) {
|
||||
prev = var_hash;
|
||||
var_hash = var_hash->next;
|
||||
}
|
||||
|
||||
if (!var_hash) {
|
||||
if (!var_hash || var_hash->used_slots == VAR_ENTRIES_MAX) {
|
||||
var_hash = emalloc(sizeof(var_entries));
|
||||
var_hash->used_slots = 0;
|
||||
var_hash->next = 0;
|
||||
|
||||
if (!(*var_hashx)->first)
|
||||
if (!(*var_hashx)->first) {
|
||||
(*var_hashx)->first = var_hash;
|
||||
else
|
||||
prev->next = var_hash;
|
||||
} else {
|
||||
((var_entries *) (*var_hashx)->last)->next = var_hash;
|
||||
}
|
||||
|
||||
(*var_hashx)->last = var_hash;
|
||||
}
|
||||
|
||||
var_hash->data[var_hash->used_slots++] = *rval;
|
||||
|
@ -59,25 +57,23 @@ static inline void var_push(php_unserialize_data_t *var_hashx, zval **rval)
|
|||
|
||||
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval)
|
||||
{
|
||||
var_entries *var_hash = (*var_hashx)->first_dtor, *prev = NULL;
|
||||
var_entries *var_hash = (*var_hashx)->last_dtor;
|
||||
#if 0
|
||||
fprintf(stderr, "var_push_dtor(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(rval));
|
||||
#endif
|
||||
|
||||
while (var_hash && var_hash->used_slots == VAR_ENTRIES_MAX) {
|
||||
prev = var_hash;
|
||||
var_hash = var_hash->next;
|
||||
}
|
||||
|
||||
if (!var_hash) {
|
||||
if (!var_hash || var_hash->used_slots == VAR_ENTRIES_MAX) {
|
||||
var_hash = emalloc(sizeof(var_entries));
|
||||
var_hash->used_slots = 0;
|
||||
var_hash->next = 0;
|
||||
|
||||
if (!(*var_hashx)->first_dtor)
|
||||
if (!(*var_hashx)->first_dtor) {
|
||||
(*var_hashx)->first_dtor = var_hash;
|
||||
else
|
||||
prev->next = var_hash;
|
||||
} else {
|
||||
((var_entries *) (*var_hashx)->last_dtor)->next = var_hash;
|
||||
}
|
||||
|
||||
(*var_hashx)->last_dtor = var_hash;
|
||||
}
|
||||
|
||||
Z_ADDREF_PP(rval);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue