Bug 700659 - Slay nsHashSets in netwerk/protocol. r=mcmanus
authorNathan Froyd <froydnj@mozilla.com>
Mon, 27 Feb 2012 11:20:29 -0500
changeset 87952 949612a1831708ceff8b0840fbd307144b82c974
parent 87951 e0913432b56e43843dd4b7bcd5c6e2cbeb32d4f6
child 87953 bca0ee06670c1bfc610c890f3cc4dfd41d51770a
push id22164
push usermbrubeck@mozilla.com
push dateWed, 29 Feb 2012 18:48:10 +0000
treeherdermozilla-central@3812d0ce274e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs700659
milestone13.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 700659 - Slay nsHashSets in netwerk/protocol. r=mcmanus
netwerk/protocol/http/nsHttpConnectionMgr.cpp
netwerk/protocol/http/nsHttpConnectionMgr.h
--- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp
@@ -576,43 +576,40 @@ nsHttpConnectionMgr::ReportSpdyAlternate
     // The Alternate Protocol hash is protected under the monitor because
     // it is read from both the main and the network thread.
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
     // Check to see if this is already present
     if (mAlternateProtocolHash.Contains(hostPortKey))
         return;
     
-    if (mAlternateProtocolHash.mHashTable.entryCount > 2000)
-        PL_DHashTableEnumerate(&mAlternateProtocolHash.mHashTable,
-                               &nsHttpConnectionMgr::TrimAlternateProtocolHash,
-                               this);
+    if (mAlternateProtocolHash.Count() > 2000)
+        mAlternateProtocolHash.EnumerateEntries(&TrimAlternateProtocolHash,
+						this);
     
-    mAlternateProtocolHash.Put(hostPortKey);
+    mAlternateProtocolHash.PutEntry(hostPortKey);
 }
 
 void
 nsHttpConnectionMgr::RemoveSpdyAlternateProtocol(nsACString &hostPortKey)
 {
     // The Alternate Protocol hash is protected under the monitor because
     // it is read from both the main and the network thread.
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
-    return mAlternateProtocolHash.Remove(hostPortKey);
+    return mAlternateProtocolHash.RemoveEntry(hostPortKey);
 }
 
 PLDHashOperator
-nsHttpConnectionMgr::TrimAlternateProtocolHash(PLDHashTable *table,
-                                               PLDHashEntryHdr *hdr,
-                                               PRUint32 number,
+nsHttpConnectionMgr::TrimAlternateProtocolHash(nsCStringHashKey *entry,
                                                void *closure)
 {
     nsHttpConnectionMgr *self = (nsHttpConnectionMgr *) closure;
     
-    if (self->mAlternateProtocolHash.mHashTable.entryCount > 2000)
+    if (self->mAlternateProtocolHash.Count() > 2000)
         return PL_DHASH_REMOVE;
     return PL_DHASH_STOP;
 }
 
 nsHttpConnectionMgr::nsConnectionEntry *
 nsHttpConnectionMgr::GetSpdyPreferredEnt(nsConnectionEntry *aOriginalEntry)
 {
     if (!gHttpHandler->IsSpdyEnabled() ||
--- a/netwerk/protocol/http/nsHttpConnectionMgr.h
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.h
@@ -44,17 +44,16 @@
 #include "nsHttpTransaction.h"
 #include "nsTArray.h"
 #include "nsThreadUtils.h"
 #include "nsClassHashtable.h"
 #include "nsDataHashtable.h"
 #include "nsAutoPtr.h"
 #include "mozilla/ReentrantMonitor.h"
 #include "nsISocketTransportService.h"
-#include "nsHashSets.h"
 
 #include "nsIObserver.h"
 #include "nsITimer.h"
 #include "nsIX509Cert3.h"
 
 class nsHttpPipeline;
 
 //-----------------------------------------------------------------------------
@@ -420,20 +419,19 @@ private:
     // the connection table
     //
     // this table is indexed by connection key.  each entry is a
     // nsConnectionEntry object.
     //
     nsClassHashtable<nsCStringHashKey, nsConnectionEntry> mCT;
 
     // mAlternateProtocolHash is used only for spdy/2 upgrades for now
-    nsCStringHashSet mAlternateProtocolHash; // protected by the monitor
-    static PLDHashOperator TrimAlternateProtocolHash(PLDHashTable *table,
-                                                     PLDHashEntryHdr *hdr,
-                                                     PRUint32 number,
+    // protected by the monitor
+    nsTHashtable<nsCStringHashKey> mAlternateProtocolHash;
+    static PLDHashOperator TrimAlternateProtocolHash(nsCStringHashKey *entry,
                                                      void *closure);
     // Read Timeout Tick handlers
     void ActivateTimeoutTick();
     void ReadTimeoutTick();
     static PLDHashOperator ReadTimeoutTickCB(const nsACString &key,
                                              nsAutoPtr<nsConnectionEntry> &ent,
                                              void *closure);
 };