combine two arrays in XMLHttpRequestException.cpp into one
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Apr 2012 05:30:05 +0000 (05:30 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Apr 2012 05:30:05 +0000 (05:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83443

Patch by Lu Guanqun <guanqun.lu@intel.com> on 2012-04-09
Reviewed by Kentaro Hara.

No new tests requied.

* xml/XMLHttpRequestException.cpp:
(XMLHttpRequestExceptionNameDescription):
(WebCore):
(WebCore::XMLHttpRequestException::initializeDescription):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@113679 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/xml/XMLHttpRequestException.cpp

index e26dd0b..7820ed6 100644 (file)
@@ -1,3 +1,17 @@
+2012-04-09  Lu Guanqun  <guanqun.lu@intel.com>
+
+        combine two arrays in XMLHttpRequestException.cpp into one
+        https://bugs.webkit.org/show_bug.cgi?id=83443
+
+        Reviewed by Kentaro Hara.
+
+        No new tests requied.
+
+        * xml/XMLHttpRequestException.cpp:
+        (XMLHttpRequestExceptionNameDescription):
+        (WebCore):
+        (WebCore::XMLHttpRequestException::initializeDescription):
+
 2012-04-09  No'am Rosenthal  <noam.rosenthal@nokia.com>
 
         [WK2] Enable using a single ShareableBitmap for multiple updates
index 9e74aac..c06c07c 100644 (file)
 
 namespace WebCore {
 
-// FIXME: This should be an array of structs to pair the names and descriptions.
-static const char* const exceptionNames[] = {
-    "NETWORK_ERR",
-    "ABORT_ERR"
+static struct XMLHttpRequestExceptionNameDescription {
+    const char* const name;
+    const char* const description;
+} exceptions[] = {
+    { "NETWORK_ERR", "A network error occurred in synchronous requests." },
+    { "ABORT_ERR", "The user aborted a request in synchronous requests." }
 };
 
-static const char* const exceptionDescriptions[] = {
-    "A network error occurred in synchronous requests.",
-    "The user aborted a request in synchronous requests."
-};
-
-COMPILE_ASSERT(WTF_ARRAY_LENGTH(exceptionNames) == WTF_ARRAY_LENGTH(exceptionDescriptions), XMLHttpRequestExceptionTablesMustMatch);
-
 bool XMLHttpRequestException::initializeDescription(ExceptionCode ec, ExceptionCodeDescription* description)
 {
     if (ec < XMLHttpRequestExceptionOffset || ec > XMLHttpRequestExceptionMax)
@@ -53,11 +48,11 @@ bool XMLHttpRequestException::initializeDescription(ExceptionCode ec, ExceptionC
     description->code = ec - XMLHttpRequestExceptionOffset;
     description->type = XMLHttpRequestExceptionType;
 
-    size_t tableSize = WTF_ARRAY_LENGTH(exceptionNames);
+    size_t tableSize = WTF_ARRAY_LENGTH(exceptions);
     size_t tableIndex = ec - NETWORK_ERR;
 
-    description->name = tableIndex < tableSize ? exceptionNames[tableIndex] : 0;
-    description->description = tableIndex < tableSize ? exceptionDescriptions[tableIndex] : 0;
+    description->name = tableIndex < tableSize ? exceptions[tableIndex].name : 0;
+    description->description = tableIndex < tableSize ? exceptions[tableIndex].description : 0;
 
     return true;
 }