From cd5aa421206501a8651baa5cb4d19a96c4374cbe Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 22 Nov 2015 17:28:52 +0000 Subject: Separate node data creation and node bloom creation. --- src/select/select.c | 55 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/src/select/select.c b/src/select/select.c index 30ea622..5fef4e4 100644 --- a/src/select/select.c +++ b/src/select/select.c @@ -581,21 +581,15 @@ static css_error css__get_parent_bloom(void *parent, return CSS_OK; } -/** - * Set a node's data - * - * \param parent Node to set node data for - * \param handler Dispatch table of handler functions - * \param pw Client-specific private data for handler functions - * \return CSS_OK on success, appropriate error otherwise. - */ -static css_error css__set_node_data(void *node, css_select_state *state, - css_select_handler *handler, void *pw) +static css_error css__create_node_bloom( + css_bloom **node_bloom, css_select_state *state) { css_error error; css_bloom *bloom; lwc_hash hash; + *node_bloom = NULL; + /* Create the node's bloom */ bloom = calloc(sizeof(css_bloom), CSS_BLOOM_SIZE); if (bloom == NULL) { @@ -635,14 +629,7 @@ static css_error css__set_node_data(void *node, css_select_state *state, /* Merge parent bloom into node bloom */ css_bloom_merge(state->node_data->bloom, bloom); - state->node_data->bloom = bloom; - - /* Set node bloom filter */ - error = handler->set_libcss_node_data(pw, node, state->node_data); - if (error != CSS_OK) - goto cleanup; - - state->node_data = NULL; + *node_bloom = bloom; return CSS_OK; @@ -652,6 +639,38 @@ cleanup: return error; } +/** + * Set a node's data + * + * \param node Node to set node data for + * \param state Selection state for node + * \param handler Dispatch table of handler functions + * \param pw Client-specific private data for handler functions + * \return CSS_OK on success, appropriate error otherwise. + */ +static css_error css__set_node_data(void *node, css_select_state *state, + css_select_handler *handler, void *pw) +{ + css_error error; + css_bloom *bloom; + + /* Set node bloom filter */ + error = css__create_node_bloom(&bloom, state); + if (error != CSS_OK) { + return error; + } + state->node_data->bloom = bloom; + + error = handler->set_libcss_node_data(pw, node, state->node_data); + if (error != CSS_OK) { + return error; + } + + state->node_data = NULL; + + return CSS_OK; +} + /** * Select a style for the given node -- cgit v1.2.3