Bug 1186791 (part 2) - Replace nsBaseHashtable::EnumerateRead() calls in storage/ with iterators. r=mak.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 29 Oct 2015 16:04:42 -0700
changeset 270313 15aad0a5b3cb1695bacaf3e4ecb40339cb7a2a1c
parent 270312 582ecb12478ae567b439bb5aa01a1ac3b9551e61
child 270314 234e629e87cc1761289130f85039bba64a6ea07e
push id67313
push usernnethercote@mozilla.com
push dateFri, 30 Oct 2015 02:36:20 +0000
treeherdermozilla-inbound@234e629e87cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1186791
milestone45.0a1
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 1186791 (part 2) - Replace nsBaseHashtable::EnumerateRead() calls in storage/ with iterators. r=mak.
storage/mozStorageConnection.cpp
--- a/storage/mozStorageConnection.cpp
+++ b/storage/mozStorageConnection.cpp
@@ -189,34 +189,16 @@ Module gModules[] = {
 //// Local Functions
 
 void tracefunc (void *aClosure, const char *aStmt)
 {
   MOZ_LOG(gStorageLog, LogLevel::Debug, ("sqlite3_trace on %p for '%s'", aClosure,
                                      aStmt));
 }
 
-struct FFEArguments
-{
-    nsISupports *target;
-    bool found;
-};
-PLDHashOperator
-findFunctionEnumerator(const nsACString &aKey,
-                       Connection::FunctionInfo aData,
-                       void *aUserArg)
-{
-  FFEArguments *args = static_cast<FFEArguments *>(aUserArg);
-  if (aData.function == args->target) {
-    args->found = true;
-    return PL_DHASH_STOP;
-  }
-  return PL_DHASH_NEXT;
-}
-
 PLDHashOperator
 copyFunctionEnumerator(const nsACString &aKey,
                        Connection::FunctionInfo aData,
                        void *aUserArg)
 {
   NS_PRECONDITION(aData.type == Connection::FunctionInfo::SIMPLE ||
                   aData.type == Connection::FunctionInfo::AGGREGATE,
                   "Invalid function type!");
@@ -859,19 +841,23 @@ Connection::databaseElementExists(enum D
 
   return convertResultCode(srv);
 }
 
 bool
 Connection::findFunctionByInstance(nsISupports *aInstance)
 {
   sharedDBMutex.assertCurrentThreadOwns();
-  FFEArguments args = { aInstance, false };
-  (void)mFunctions.EnumerateRead(findFunctionEnumerator, &args);
-  return args.found;
+
+  for (auto iter = mFunctions.Iter(); !iter.Done(); iter.Next()) {
+    if (iter.UserData().function == aInstance) {
+      return true;
+    }
+  }
+  return false;
 }
 
 /* static */ int
 Connection::sProgressHelper(void *aArg)
 {
   Connection *_this = static_cast<Connection *>(aArg);
   return _this->progressHandler();
 }