Skip to content

Commit

Permalink
Use on-stack key creation to speed up hash lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Nov 29, 2019
1 parent abd4829 commit 9547f83
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions xdebug_code_coverage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 9547f83

Please sign in to comment.