Skip to content
Permalink
Browse files

Use on-stack key creation to speed up hash lookups

  • Loading branch information
derickr committed Nov 29, 2019
1 parent abd4829 commit 9547f8378643a5aefae07fcaafa9d69934ed34b5
Showing with 6 additions and 7 deletions.
  1. +6 −7 xdebug_code_coverage.c
@@ -715,7 +715,7 @@ static int xdebug_find_jumps(zend_op_array *opa, unsigned int position, size_t *
#if ZEND_USE_ABS_JMP_ADDR
zend_op *base_address = &(opa->opcodes[0]);
#endif

zend_op opcode = opa->opcodes[position];
if (opcode.opcode == ZEND_JMP) {
jumps[0] = XDEBUG_ZNODE_JMP_LINE(opcode.op1, position, base_address);
@@ -1051,17 +1051,16 @@ static int mark_class_as_visited(zend_class_entry *ce)
{
int already_visited = 0;
void *dummy; /* we only care about key existence, not value */
char *key = xdebug_sprintf("%08X", (uintptr_t) ce);
size_t key_len = strlen(key);
char key[17];

snprintf(key, 17, "%016lX", (uintptr_t) ce);

if (xdebug_hash_find(XG(visited_classes), key, key_len, (void*) &dummy)) {
if (xdebug_hash_find(XG(visited_classes), key, 16, (void*) &dummy)) {
already_visited = 1;
} else {
xdebug_hash_add(XG(visited_classes), key, key_len, NULL);
xdebug_hash_add(XG(visited_classes), key, 16, NULL);
}

xdfree(key);

return already_visited;
}

0 comments on commit 9547f83

Please sign in to comment.
You can’t perform that action at this time.