Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary NULL checks and multiple Null checks #30

Open
shivramsrivastava opened this issue Jan 25, 2019 · 0 comments
Open

Unnecessary NULL checks and multiple Null checks #30

shivramsrivastava opened this issue Jan 25, 2019 · 0 comments

Comments

@shivramsrivastava
Copy link

NULL check is done in so many places where it is not required.

eg:- CHECK_NOTNULL(res_node);//there is no operation is done on it just passing to another function.

void FlowGraphManager::UpdateResourceNode(
FlowGraphNode* res_node,
queue<TDOrNodeWrapper*>* node_queue,
unordered_set<uint64_t>* marked_nodes) {
CHECK_NOTNULL(res_node);
UpdateResOutgoingArcs(res_node, node_queue, marked_nodes);
}

void FlowGraphManager::UpdateFlowGraph(
queue<TDOrNodeWrapper*>* node_queue,
unordered_set<uint64_t>* marked_nodes) {
CHECK_NOTNULL(node_queue);
CHECK_NOTNULL(marked_nodes); //Not required
while (!node_queue->empty()) {
TDOrNodeWrapper* cur_node = node_queue->front();
node_queue->pop();
if (!cur_node->node_) {
// We're handling a task that doesn't have an associated flow graph node.
UpdateChildrenTasks(cur_node->td_ptr_, node_queue, marked_nodes);
delete cur_node;
continue;
}
if (cur_node->node_->IsTaskNode()) {
UpdateTaskNode(cur_node->node_, node_queue, marked_nodes);
UpdateChildrenTasks(cur_node->td_ptr_, node_queue, marked_nodes);
} else if (cur_node->node_->IsEquivalenceClassNode()) {
UpdateEquivClassNode(cur_node->node_, node_queue, marked_nodes);
} else if (cur_node->node_->IsResourceNode()) {
UpdateResourceNode(cur_node->node_, node_queue, marked_nodes);
} else {
LOG(FATAL) << "Unexpected node type: " << cur_node->node_->type_;
}
delete cur_node;
}

Note: have reservation that there are multiple NULL check as well present in the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant