Attempt to make XPC_XOW_ClassNeedsXOW faster. bug 444779, r=jorendorff/jst sr=jst
authorBlake Kaplan <mrbkap@gmail.com>
Wed, 23 Jul 2008 12:55:57 -0400
changeset 16146 41d5a8915ca2c03a0b1255b3f8ff13215e67b154
parent 16145 20bff6157770884464c41d005ad06a83b640f465
child 16148 403582828a52ea820cc2128b023efa2c163ae77d
push idunknown
push userunknown
push dateunknown
reviewersjorendorff, jst, jst
bugs444779
milestone1.9.1a2pre
Attempt to make XPC_XOW_ClassNeedsXOW faster. bug 444779, r=jorendorff/jst sr=jst
js/src/xpconnect/src/XPCWrapper.h
--- a/js/src/xpconnect/src/XPCWrapper.h
+++ b/js/src/xpconnect/src/XPCWrapper.h
@@ -79,21 +79,33 @@ XPC_XOW_WrapperMoved(JSContext *cx, XPCW
                      XPCWrappedNativeScope *newScope);
 
 nsresult
 CanAccessWrapper(JSContext *cx, JSObject *wrappedObj);
 
 inline JSBool
 XPC_XOW_ClassNeedsXOW(const char *name)
 {
-  // TODO Make a perfect hash of these and use that?
-  return !strcmp(name, "Window")            ||
-         !strcmp(name, "Location")          ||
-         !strcmp(name, "HTMLIFrameElement") ||
-         !strcmp(name, "HTMLFrameElement");
+  switch (*name) {
+    case 'W':
+      return strcmp(++name, "indow") == 0;
+    case 'L':
+      return strcmp(++name, "ocation") == 0;
+    case 'H':
+      if (strncmp(++name, "TML", 3))
+        break;
+      name += 3;
+      if (*name == 'I')
+        ++name;
+      return strcmp(name, "FrameElement") == 0;
+    default:
+      break;
+  }
+
+  return JS_FALSE;
 }
 
 extern JSExtendedClass sXPC_XOW_JSClass;
 extern JSExtendedClass sXPC_SJOW_JSClass;
 
 // This class wraps some common functionality between the three existing
 // wrappers. Its main purpose is to allow XPCCrossOriginWrapper to act both
 // as an XPCSafeSJSObjectWrapper and as an XPCNativeWrapper when required to