8000 py/map: Allow to trace rehashing operations. · lvgl/lv_micropython@a35d923 · GitHub
[go: up one dir, main page]

Skip to content

Commit a35d923

Browse files
committed
py/map: Allow to trace rehashing operations.
1 parent 2b00181 commit a35d923

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

py/map.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@
3333
#include "py/misc.h"
3434
#include "py/runtime.h"
3535

36+
#if MICROPY_DEBUG_VERBOSE // print debugging info
37+
#define DEBUG_PRINT (1)
38+
#else // don't print debugging info
39+
#define DEBUG_PRINT (0)
40+
#define DEBUG_printf(...) (void)0
41+
#endif
42+
3643
// Fixed empty map. Useful when need to call kw-receiving functions
3744
// without any keywords from C, etc.
3845
const mp_map_t mp_const_empty_map = {
@@ -114,6 +121,7 @@ void mp_map_clear(mp_map_t *map) {
114121
STATIC void mp_map_rehash(mp_map_t *map) {
115122
size_t old_alloc = map->alloc;
116123
size_t new_alloc = get_hash_alloc_greater_or_equal_to(map->alloc + 1);
124+
DEBUG_printf("mp_map_rehash(%p): " UINT_FMT " -> " UINT_FMT "\n", map, old_alloc, new_alloc);
117125
mp_map_elem_t *old_table = map->table;
118126
mp_map_elem_t *new_table = m_new0(mp_map_elem_t, new_alloc);
119127
// If we reach this point, table resizing succeeded, now we can edit the old map.

0 commit comments

Comments
 (0)
0