livetree: simplify condition in get_node_by_path
The "strlen && strprefixeq" check in get_node_by_path is excessive, since strlen is checked in strprefixeq macro internally. Thus, "strlen(child->name) == p-path" conjunct duplicates after macro expansion and could be removed. Signed-off-by: Denis Efremov <efremov@linux.com> Message-Id: <20190827204148.20604-1-efremov@linux.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
committed by
David Gibson
parent
b8d6eca782
commit
5345db19f6
@@ -526,8 +526,7 @@ struct node *get_node_by_path(struct node *tree, const char *path)
|
|||||||
p = strchr(path, '/');
|
p = strchr(path, '/');
|
||||||
|
|
||||||
for_each_child(tree, child) {
|
for_each_child(tree, child) {
|
||||||
if (p && (strlen(child->name) == p-path) &&
|
if (p && strprefixeq(path, p - path, child->name))
|
||||||
strprefixeq(path, p - path, child->name))
|
|
||||||
return get_node_by_path(child, p+1);
|
return get_node_by_path(child, p+1);
|
||||||
else if (!p && streq(path, child->name))
|
else if (!p && streq(path, child->name))
|
||||||
return child;
|
return child;
|
||||||
|
|||||||
Reference in New Issue
Block a user