Nikolay Sivov : ole32: Use precomposed table for GUID from string conversion.
Alexandre Julliard
julliard at winehq.org
Tue Feb 11 13:32:40 CST 2014
Module: wine
Branch: master
Commit: 747c649d99dceffd03bb1458fa17049618501b67
URL: http://source.winehq.org/git/wine.git/?a=commit;h=747c649d99dceffd03bb1458fa17049618501b67
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Tue Feb 11 08:34:41 2014 +0400
ole32: Use precomposed table for GUID from string conversion.
---
dlls/ole32/compobj.c | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c
index 719d9de..e615599 100644
--- a/dlls/ole32/compobj.c
+++ b/dlls/ole32/compobj.c
@@ -2065,11 +2065,21 @@ static inline BOOL is_valid_hex(WCHAR c)
return TRUE;
}
+static const BYTE guid_conv_table[256] =
+{
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 */
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, /* 0x30 */
+ 0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 */
+ 0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf /* 0x60 */
+};
+
/* conversion helper for CLSIDFromString/IIDFromString */
static BOOL guid_from_string(LPCWSTR s, GUID *id)
{
int i;
- BYTE table[256];
if (!s || s[0]!='{') {
memset( id, 0, sizeof (CLSID) );
@@ -2079,37 +2089,26 @@ static BOOL guid_from_string(LPCWSTR s, GUID *id)
TRACE("%s -> %p\n", debugstr_w(s), id);
- /* quick lookup table */
- memset(table, 0, 256);
-
- for (i = 0; i < 10; i++) {
- table['0' + i] = i;
- }
- for (i = 0; i < 6; i++) {
- table['A' + i] = i+10;
- table['a' + i] = i+10;
- }
-
/* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
id->Data1 = 0;
for (i = 1; i < 9; i++) {
if (!is_valid_hex(s[i])) return FALSE;
- id->Data1 = (id->Data1 << 4) | table[s[i]];
+ id->Data1 = (id->Data1 << 4) | guid_conv_table[s[i]];
}
if (s[9]!='-') return FALSE;
id->Data2 = 0;
for (i = 10; i < 14; i++) {
if (!is_valid_hex(s[i])) return FALSE;
- id->Data2 = (id->Data2 << 4) | table[s[i]];
+ id->Data2 = (id->Data2 << 4) | guid_conv_table[s[i]];
}
if (s[14]!='-') return FALSE;
id->Data3 = 0;
for (i = 15; i < 19; i++) {
if (!is_valid_hex(s[i])) return FALSE;
- id->Data3 = (id->Data3 << 4) | table[s[i]];
+ id->Data3 = (id->Data3 << 4) | guid_conv_table[s[i]];
}
if (s[19]!='-') return FALSE;
@@ -2119,7 +2118,7 @@ static BOOL guid_from_string(LPCWSTR s, GUID *id)
i++;
}
if (!is_valid_hex(s[i]) || !is_valid_hex(s[i+1])) return FALSE;
- id->Data4[(i-20)/2] = table[s[i]] << 4 | table[s[i+1]];
+ id->Data4[(i-20)/2] = guid_conv_table[s[i]] << 4 | guid_conv_table[s[i+1]];
}
if (s[37] == '}' && s[38] == '\0')
More information about the wine-cvs
mailing list