Commit 5eec1429 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

mshtml: Use binary search when looking up events by name.

Since they're already sorted (except for DOMContentLoaded because of case sensitivity). Signed-off-by: 's avatarGabriel Ivăncescu <gabrielopcode@gmail.com> Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 105e6b83
...@@ -105,7 +105,10 @@ typedef struct { ...@@ -105,7 +105,10 @@ typedef struct {
#define EVENT_MOUSE_TO_RELATED 0x0100 #define EVENT_MOUSE_TO_RELATED 0x0100
#define EVENT_MOUSE_FROM_RELATED 0x0200 #define EVENT_MOUSE_FROM_RELATED 0x0200
/* Keep these sorted case sensitively */
static const event_info_t event_info[] = { static const event_info_t event_info[] = {
{L"DOMContentLoaded", EVENT_TYPE_EVENT, 0,
EVENT_DEFAULTLISTENER | EVENT_BUBBLES | EVENT_CANCELABLE},
{L"abort", EVENT_TYPE_EVENT, DISPID_EVMETH_ONABORT, {L"abort", EVENT_TYPE_EVENT, DISPID_EVMETH_ONABORT,
EVENT_BIND_TO_TARGET}, EVENT_BIND_TO_TARGET},
{L"animationend", EVENT_TYPE_EVENT, DISPID_EVPROP_ONANIMATIONEND, {L"animationend", EVENT_TYPE_EVENT, DISPID_EVPROP_ONANIMATIONEND,
...@@ -128,8 +131,6 @@ static const event_info_t event_info[] = { ...@@ -128,8 +131,6 @@ static const event_info_t event_info[] = {
EVENT_FIXME | EVENT_BUBBLES}, EVENT_FIXME | EVENT_BUBBLES},
{L"dblclick", EVENT_TYPE_MOUSE, DISPID_EVMETH_ONDBLCLICK, {L"dblclick", EVENT_TYPE_MOUSE, DISPID_EVMETH_ONDBLCLICK,
EVENT_DEFAULTLISTENER | EVENT_BUBBLES | EVENT_CANCELABLE}, EVENT_DEFAULTLISTENER | EVENT_BUBBLES | EVENT_CANCELABLE},
{L"DOMContentLoaded", EVENT_TYPE_EVENT, 0,
EVENT_DEFAULTLISTENER | EVENT_BUBBLES | EVENT_CANCELABLE},
{L"drag", EVENT_TYPE_DRAG, DISPID_EVMETH_ONDRAG, {L"drag", EVENT_TYPE_DRAG, DISPID_EVMETH_ONDRAG,
EVENT_FIXME | EVENT_BUBBLES | EVENT_CANCELABLE}, EVENT_FIXME | EVENT_BUBBLES | EVENT_CANCELABLE},
{L"dragstart", EVENT_TYPE_DRAG, DISPID_EVMETH_ONDRAGSTART, {L"dragstart", EVENT_TYPE_DRAG, DISPID_EVMETH_ONDRAGSTART,
...@@ -192,11 +193,15 @@ C_ASSERT(ARRAY_SIZE(event_info) == EVENTID_LAST); ...@@ -192,11 +193,15 @@ C_ASSERT(ARRAY_SIZE(event_info) == EVENTID_LAST);
static eventid_t str_to_eid(const WCHAR *str) static eventid_t str_to_eid(const WCHAR *str)
{ {
int i; unsigned i, a = 0, b = ARRAY_SIZE(event_info);
int c;
for(i=0; i < ARRAY_SIZE(event_info); i++) { while(a < b) {
if(!wcscmp(event_info[i].name, str)) i = (a + b) / 2;
if(!(c = wcscmp(event_info[i].name, str)))
return i; return i;
if(c > 0) b = i;
else a = i + 1;
} }
return EVENTID_LAST; return EVENTID_LAST;
...@@ -204,14 +209,18 @@ static eventid_t str_to_eid(const WCHAR *str) ...@@ -204,14 +209,18 @@ static eventid_t str_to_eid(const WCHAR *str)
static eventid_t attr_to_eid(const WCHAR *str) static eventid_t attr_to_eid(const WCHAR *str)
{ {
int i; unsigned i, a = 0, b = ARRAY_SIZE(event_info);
int c;
if((str[0] != 'o' && str[0] != 'O') || (str[1] != 'n' && str[1] != 'N')) if((str[0] != 'o' && str[0] != 'O') || (str[1] != 'n' && str[1] != 'N'))
return EVENTID_LAST; return EVENTID_LAST;
for(i=0; i < ARRAY_SIZE(event_info); i++) { while(a < b) {
if(!wcscmp(event_info[i].name, str+2) && event_info[i].dispid) i = (a + b) / 2;
return i; if(!(c = wcscmp(event_info[i].name, str+2)))
return event_info[i].dispid ? i : EVENTID_LAST;
if(c > 0) b = i;
else a = i + 1;
} }
return EVENTID_LAST; return EVENTID_LAST;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
*/ */
typedef enum { typedef enum {
EVENTID_DOMCONTENTLOADED,
EVENTID_ABORT, EVENTID_ABORT,
EVENTID_ANIMATIONEND, EVENTID_ANIMATIONEND,
EVENTID_ANIMATIONSTART, EVENTID_ANIMATIONSTART,
...@@ -28,7 +29,6 @@ typedef enum { ...@@ -28,7 +29,6 @@ typedef enum {
EVENTID_CONTEXTMENU, EVENTID_CONTEXTMENU,
EVENTID_DATAAVAILABLE, EVENTID_DATAAVAILABLE,
EVENTID_DBLCLICK, EVENTID_DBLCLICK,
EVENTID_DOMCONTENTLOADED,
EVENTID_DRAG, EVENTID_DRAG,
EVENTID_DRAGSTART, EVENTID_DRAGSTART,
EVENTID_ERROR, EVENTID_ERROR,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment