diff options
author | James Cloos <cloos@jhcloos.com> | 2008-07-23 13:17:33 -0400 |
---|---|---|
committer | James Cloos <cloos@jhcloos.com> | 2008-07-23 13:17:33 -0400 |
commit | ab6557fcd4bb4fd580bb1727dc8764f7dfb2cb30 (patch) | |
tree | b2efbe77d686e403d75614d70eb0c58b8602ce8e /os | |
parent | b699364b1c807d29666633523f5b5a608a07a8ee (diff) |
Optimize commit 331cc3f0799a54910a99484264f76569beeee55a
Reorder to minimize comparisons
Diffstat (limited to 'os')
-rw-r--r-- | os/oscolor.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/os/oscolor.c b/os/oscolor.c index 69eadc23e..7f6b93880 100644 --- a/os/oscolor.c +++ b/os/oscolor.c @@ -1590,19 +1590,17 @@ OsLookupColor(int screen, mid = (low + high) / 2; c = &BuiltinColors[mid]; r = strncasecmp (&BuiltinColorNames[c->name], name, len); - if (r == 0 && strlen (&BuiltinColorNames[c->name]) > len) - r++; - if (r == 0) + if (r == 0 && len == strlen (&BuiltinColorNames[c->name])) { *pred = c->red * 0x101; *pgreen = c->green * 0x101; *pblue = c->blue * 0x101; return TRUE; } - if (r > 0) - high = mid - 1; - else + if (r < 0) low = mid + 1; + else + high = mid - 1; } return FALSE; } |