cryptui: Avoid idempotent operation (Clang) (try 2)
Frédéric Delanoy
frederic.delanoy at gmail.com
Fri Oct 14 16:11:32 CDT 2011
indexLow is always 0 at that point
try 2: use standard dichotomic search
---
dlls/cryptui/main.c | 18 +++++++-----------
1 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/dlls/cryptui/main.c b/dlls/cryptui/main.c
index 9df9800..5f742d6 100644
--- a/dlls/cryptui/main.c
+++ b/dlls/cryptui/main.c
@@ -1966,23 +1966,19 @@ static struct OIDToString oidMap[] = {
static struct OIDToString *findSupportedOID(LPCSTR oid)
{
- int indexHigh = sizeof(oidMap) / sizeof(oidMap[0]) - 1, indexLow = 0, i;
- struct OIDToString *ret = NULL;
+ int indexHigh = sizeof(oidMap) / sizeof(oidMap[0]) - 1, indexLow = 0;
- for (i = (indexLow + indexHigh) / 2; !ret && indexLow <= indexHigh;
- i = (indexLow + indexHigh) / 2)
+ while (indexLow <= indexHigh)
{
- int cmp;
-
- cmp = strcmp(oid, oidMap[i].oid);
- if (!cmp)
- ret = &oidMap[i];
- else if (cmp > 0)
+ int cmp, i = (indexLow + indexHigh) / 2;
+ if (!(cmp = strcmp(oid, oidMap[i].oid)))
+ return &oidMap[i];
+ if (cmp > 0)
indexLow = i + 1;
else
indexHigh = i - 1;
}
- return ret;
+ return NULL;
}
static void add_local_oid_text_to_control(HWND text, LPCSTR oid)
--
1.7.7
More information about the wine-patches
mailing list