ole32: Use precomposed table for GUID from string conversion.
This commit is contained in:
parent
9c010d70b0
commit
747c649d99
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue