summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-09-20 06:12:08 +0000
committerDavid Robillard <d@drobilla.net>2011-09-20 06:12:08 +0000
commitbf0464d0e994aece12bfd15884a12de249666617 (patch)
tree510fbca45078c6e48b99da98cd5972ba91a35aad
parent97c4492c9c25f5cc30aa9121ee99829f66a8ffb9 (diff)
downloadzix-bf0464d0e994aece12bfd15884a12de249666617.tar.gz
zix-bf0464d0e994aece12bfd15884a12de249666617.tar.bz2
zix-bf0464d0e994aece12bfd15884a12de249666617.zip
Remove pointless loop conditional.
git-svn-id: http://svn.drobilla.net/zix/trunk@34 df6676b4-ccc9-40e5-b5d6-7c4628a128e3
-rw-r--r--src/patree.c58
1 files changed, 27 insertions, 31 deletions
diff --git a/src/patree.c b/src/patree.c
index bcda57f..fe538ba 100644
--- a/src/patree.c
+++ b/src/patree.c
@@ -251,42 +251,38 @@ zix_patree_find(const ZixPatree* t, const char* const str, char** match)
register const char* p = str;
- while (*p != '\0') {
- if (patree_find_edge(n, p[0], &child_i)) {
- assert(child_i <= n->num_children);
- ZixPatreeNode* const child = &n->children[child_i];
-
- /* Prefix compare search string and label */
- register const char* l = child->label_first;
- register const char* const l_end = child->label_last;
- while (l <= l_end) {
- if (*l++ != *p++) {
- return ZIX_STATUS_NOT_FOUND;
- }
+ while (patree_find_edge(n, p[0], &child_i)) {
+ assert(child_i <= n->num_children);
+ ZixPatreeNode* const child = &n->children[child_i];
+
+ /* Prefix compare search string and label */
+ register const char* l = child->label_first;
+ register const char* const l_end = child->label_last;
+ while (l <= l_end) {
+ if (*l++ != *p++) {
+ return ZIX_STATUS_NOT_FOUND;
}
+ }
- if (!*p) {
- /* Reached end of search string */
- if (l == l_end + 1) {
- /* Reached end of label string as well, match */
- *match = child->str;
- return *match ? ZIX_STATUS_SUCCESS : ZIX_STATUS_NOT_FOUND;
- } else {
- /* Label string is longer, no match (prefix match) */
- return ZIX_STATUS_NOT_FOUND;
- }
+ if (!*p) {
+ /* Reached end of search string */
+ if (l == l_end + 1) {
+ /* Reached end of label string as well, match */
+ *match = child->str;
+ return *match ? ZIX_STATUS_SUCCESS : ZIX_STATUS_NOT_FOUND;
} else {
- /* Didn't reach end of search string */
- if (patree_is_leaf(n)) {
- /* Hit leaf early, no match */
- return ZIX_STATUS_NOT_FOUND;
- } else {
- /* Match at this node, continue search downwards (or match) */
- n = child;
- }
+ /* Label string is longer, no match (prefix match) */
+ return ZIX_STATUS_NOT_FOUND;
}
} else {
- return ZIX_STATUS_NOT_FOUND;
+ /* Didn't reach end of search string */
+ if (patree_is_leaf(n)) {
+ /* Hit leaf early, no match */
+ return ZIX_STATUS_NOT_FOUND;
+ } else {
+ /* Match at this node, continue search downwards (or match) */
+ n = child;
+ }
}
}