mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Get rid of duplicated rotr3 implementation (#8853)
This commit is contained in:
parent
1453dde423
commit
50a3cb7cea
1 changed files with 10 additions and 5 deletions
|
@ -362,12 +362,17 @@ void *zend_shared_alloc(size_t size)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static zend_always_inline zend_ulong zend_rotr3(zend_ulong key)
|
||||
{
|
||||
return (key >> 3) | (key << ((sizeof(key) * 8) - 3));
|
||||
}
|
||||
|
||||
int zend_shared_memdup_size(void *source, size_t size)
|
||||
{
|
||||
void *old_p;
|
||||
zend_ulong key = (zend_ulong)source;
|
||||
|
||||
key = (key >> 3) | (key << ((sizeof(key) * 8) - 3)); /* key = _rotr(key, 3);*/
|
||||
key = zend_rotr3(key);
|
||||
if ((old_p = zend_hash_index_find_ptr(&ZCG(xlat_table), key)) != NULL) {
|
||||
/* we already duplicated this pointer */
|
||||
return 0;
|
||||
|
@ -383,7 +388,7 @@ static zend_always_inline void *_zend_shared_memdup(void *source, size_t size, b
|
|||
|
||||
if (get_xlat) {
|
||||
key = (zend_ulong)source;
|
||||
key = (key >> 3) | (key << ((sizeof(key) * 8) - 3)); /* key = _rotr(key, 3);*/
|
||||
key = zend_rotr3(key);
|
||||
if ((old_p = zend_hash_index_find_ptr(&ZCG(xlat_table), key)) != NULL) {
|
||||
/* we already duplicated this pointer */
|
||||
return old_p;
|
||||
|
@ -395,7 +400,7 @@ static zend_always_inline void *_zend_shared_memdup(void *source, size_t size, b
|
|||
if (set_xlat) {
|
||||
if (!get_xlat) {
|
||||
key = (zend_ulong)source;
|
||||
key = (key >> 3) | (key << ((sizeof(key) * 8) - 3)); /* key = _rotr(key, 3);*/
|
||||
key = zend_rotr3(key);
|
||||
}
|
||||
zend_hash_index_add_new_ptr(&ZCG(xlat_table), key, retval);
|
||||
}
|
||||
|
@ -535,7 +540,7 @@ void zend_shared_alloc_register_xlat_entry(const void *old, const void *new)
|
|||
{
|
||||
zend_ulong key = (zend_ulong)old;
|
||||
|
||||
key = (key >> 3) | (key << ((sizeof(key) * 8) - 3)); /* key = _rotr(key, 3);*/
|
||||
key = zend_rotr3(key);
|
||||
zend_hash_index_add_new_ptr(&ZCG(xlat_table), key, (void*)new);
|
||||
}
|
||||
|
||||
|
@ -544,7 +549,7 @@ void *zend_shared_alloc_get_xlat_entry(const void *old)
|
|||
void *retval;
|
||||
zend_ulong key = (zend_ulong)old;
|
||||
|
||||
key = (key >> 3) | (key << ((sizeof(key) * 8) - 3)); /* key = _rotr(key, 3);*/
|
||||
key = zend_rotr3(key);
|
||||
if ((retval = zend_hash_index_find_ptr(&ZCG(xlat_table), key)) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue