Skip to content
Snippets Groups Projects
Commit 2dfa3ff6 authored by Morris Jette's avatar Morris Jette
Browse files

hostlist performance improvements

Reorder some logis in the hostlist functions for performance improvement
specifically for "if (A & B) ..." move the fastest tests first (test
A should take less time than test B).
parent fd3b75a9
No related branches found
No related tags found
No related merge requests found
...@@ -1090,8 +1090,8 @@ static hostrange_t hostrange_intersect(hostrange_t h1, hostrange_t h2) ...@@ -1090,8 +1090,8 @@ static hostrange_t hostrange_intersect(hostrange_t h1, hostrange_t h2)
assert(hostrange_cmp(h1, h2) <= 0); assert(hostrange_cmp(h1, h2) <= 0);
if ((hostrange_prefix_cmp(h1, h2) == 0) if ((h1->hi > h2->lo)
&& (h1->hi > h2->lo) && (hostrange_prefix_cmp(h1, h2) == 0)
&& (hostrange_width_combine(h1, h2))) { && (hostrange_width_combine(h1, h2))) {
if (!(new = hostrange_copy(h1))) if (!(new = hostrange_copy(h1)))
...@@ -1408,8 +1408,8 @@ static int hostlist_push_range(hostlist_t hl, hostrange_t hr) ...@@ -1408,8 +1408,8 @@ static int hostlist_push_range(hostlist_t hl, hostrange_t hr)
goto error; goto error;
if (hl->nranges > 0 if (hl->nranges > 0
&& hostrange_prefix_cmp(tail, hr) == 0
&& tail->hi == hr->lo - 1 && tail->hi == hr->lo - 1
&& hostrange_prefix_cmp(tail, hr) == 0
&& hostrange_width_combine(tail, hr)) { && hostrange_width_combine(tail, hr)) {
tail->hi = hr->hi; tail->hi = hr->hi;
} else { } else {
...@@ -2448,8 +2448,8 @@ static void hostlist_collapse(hostlist_t hl) ...@@ -2448,8 +2448,8 @@ static void hostlist_collapse(hostlist_t hl)
hostrange_t hprev = hl->hr[i - 1]; hostrange_t hprev = hl->hr[i - 1];
hostrange_t hnext = hl->hr[i]; hostrange_t hnext = hl->hr[i];
if (hostrange_prefix_cmp(hprev, hnext) == 0 && if (hprev->hi == hnext->lo - 1 &&
hprev->hi == hnext->lo - 1 && hostrange_prefix_cmp(hprev, hnext) == 0 &&
hostrange_width_combine(hprev, hnext)) { hostrange_width_combine(hprev, hnext)) {
hprev->hi = hnext->hi; hprev->hi = hnext->hi;
hostlist_delete_range(hl, i); hostlist_delete_range(hl, i);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment