Bug 613457 - use *ById JSAPIs in storage (r=sdwilsh)
authorLuke Wagner <lw@mozilla.com>
Mon, 21 Mar 2011 11:37:47 -0700
changeset 64346 6afe562a0cb83cf427cfafb4b15fe403801db4bf
parent 64345 4290338c39567c175461153040dd5918931fd903
child 64347 ebd7cc5d0daa5bc97794d01bb290a39c2a58871b
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssdwilsh
bugs613457
milestone2.0b13pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 613457 - use *ById JSAPIs in storage (r=sdwilsh)
storage/src/mozStorageAsyncStatementParams.cpp
storage/src/mozStorageStatementParams.cpp
--- a/storage/src/mozStorageAsyncStatementParams.cpp
+++ b/storage/src/mozStorageAsyncStatementParams.cpp
@@ -135,25 +135,21 @@ AsyncStatementParams::NewResolve(
     PRUint32 idx = JSID_TO_INT(aId);
     // All indexes are good because we don't know how many parameters there
     // really are.
     ok = ::JS_DefineElement(aCtx, aScopeObj, idx, JSVAL_VOID, nsnull,
                             nsnull, 0);
     resolved = true;
   }
   else if (JSID_IS_STRING(aId)) {
-    JSString *str = JSID_TO_STRING(aId);
-    size_t nameLength;
-    const jschar *nameChars = ::JS_GetInternedStringCharsAndLength(str, &nameLength);
-
     // We are unable to tell if there's a parameter with this name and so
     // we must assume that there is.  This screws the rest of the prototype
     // chain, but people really shouldn't be depending on this anyways.
-    ok = ::JS_DefineUCProperty(aCtx, aScopeObj, nameChars, nameLength,
-                               JSVAL_VOID, nsnull, nsnull, 0);
+    ok = ::JS_DefinePropertyById(aCtx, aScopeObj, aId, JSVAL_VOID, nsnull,
+                                 nsnull, 0);
     resolved = true;
   }
 
   *_retval = ok;
   *_objp = resolved && ok ? aScopeObj : nsnull;
   return NS_OK;
 }
 
--- a/storage/src/mozStorageStatementParams.cpp
+++ b/storage/src/mozStorageStatementParams.cpp
@@ -213,23 +213,22 @@ StatementParams::NewResolve(nsIXPConnect
   else if (JSID_IS_STRING(aId)) {
     JSString *str = JSID_TO_STRING(aId);
     size_t nameLength;
     const jschar *nameChars = JS_GetStringCharsAndLength(aCtx, str, &nameLength);
     NS_ENSURE_TRUE(nameChars, NS_ERROR_UNEXPECTED);
 
     // Check to see if there's a parameter with this name, and if not, let
     // the rest of the prototype chain be checked.
-    NS_ConvertUTF16toUTF8 name(reinterpret_cast<const PRUnichar *>(nameChars),
-                               nameLength);
+    NS_ConvertUTF16toUTF8 name(nameChars, nameLength);
     PRUint32 idx;
     nsresult rv = mStatement->GetParameterIndex(name, &idx);
     if (NS_SUCCEEDED(rv)) {
-      ok = ::JS_DefineUCProperty(aCtx, aScopeObj, nameChars, nameLength,
-                                 JSVAL_VOID, nsnull, nsnull, JSPROP_ENUMERATE);
+      ok = ::JS_DefinePropertyById(aCtx, aScopeObj, aId, JSVAL_VOID, nsnull,
+                                   nsnull, JSPROP_ENUMERATE);
       resolved = true;
     }
   }
 
   *_retval = ok;
   *_objp = resolved && ok ? aScopeObj : nsnull;
   return NS_OK;
 }