Closed xdeng closed 5 years ago
When the amount of data exceeds 10,000, every time you look from scratch, the efficiency is very low. I tried to change it to
void plist_dict_next_item(plist_t node, plist_dict_iter iter, char **key, plist_t *val) { uint32_t* iter_int = (uint32_t*) iter; if (key) { *key = NULL; } if (val) { *val = NULL; } if (node && PLIST_DICT == plist_get_node_type(node) && *iter_int < node_n_children(node)) { node_t* child = node_nth_child(node, *iter_int); if (key) { plist_get_key_val((plist_t)child, key); } if (val) { *val = (plist_t)node_next_sibling(child); } *iter_int += 2; } return; }
Run time can be reduced by half, But still not fast enough
The best way is plist_dict_iter == node_t* This is the fastest, Time complexity is O(1).
See 3f967317479acc4b98594b4b86a2787cbd2aa1f1.
@nikias Great! The code is the same as I thought.
When the amount of data exceeds 10,000, every time you look from scratch, the efficiency is very low. I tried to change it to
Run time can be reduced by half, But still not fast enough