Backout 35bf0d62cc30 (Bug 726002). rs=dcamp a=mfinkle
authorGian-Carlo Pascutto <gpascutto@mozilla.com>
Fri, 20 Apr 2012 07:46:46 +0200
changeset 95344 984300ab12826df098d2752dfd5e4d8066e0b5d4
parent 95343 01d2f5d68c15f96ce7c4b73df51d3552873fb827
child 95345 e5af6f193e2a17b86444ad12481042bec3f69135
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdcamp, mfinkle
bugs726002
milestone14.0a1
backs out35bf0d62cc305d4caf00aeb448cb93a915462a83
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
Backout 35bf0d62cc30 (Bug 726002). rs=dcamp a=mfinkle
toolkit/components/url-classifier/Classifier.cpp
toolkit/components/url-classifier/HashStore.h
toolkit/components/url-classifier/LookupCache.cpp
toolkit/components/url-classifier/LookupCache.h
--- a/toolkit/components/url-classifier/Classifier.cpp
+++ b/toolkit/components/url-classifier/Classifier.cpp
@@ -526,17 +526,16 @@ Classifier::ApplyTableUpdates(nsTArray<T
   if (!prefixSet) {
     return NS_ERROR_FAILURE;
   }
   nsTArray<PRUint32> AddPrefixHashes;
   rv = prefixSet->GetPrefixes(&AddPrefixHashes);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = store->AugmentAdds(AddPrefixHashes);
   NS_ENSURE_SUCCESS(rv, rv);
-  AddPrefixHashes.Clear();
 
   uint32 applied = 0;
   bool updateFreshness = false;
 
   for (uint32 i = 0; i < aUpdates->Length(); i++) {
     TableUpdate *update = aUpdates->ElementAt(i);
     if (!update || !update->TableName().Equals(store->TableName()))
       continue;
--- a/toolkit/components/url-classifier/HashStore.h
+++ b/toolkit/components/url-classifier/HashStore.h
@@ -115,20 +115,20 @@ public:
 
   const nsCString& TableName() const { return mTableName; };
 
   nsresult Open();
   nsresult AugmentAdds(const nsTArray<PRUint32>& aPrefixes);
 
   ChunkSet& AddChunks() { return mAddChunks; }
   ChunkSet& SubChunks() { return mSubChunks; }
-  AddPrefixArray& AddPrefixes() { return mAddPrefixes; }
-  AddCompleteArray& AddCompletes() { return mAddCompletes; }
-  SubPrefixArray& SubPrefixes() { return mSubPrefixes; }
-  SubCompleteArray& SubCompletes() { return mSubCompletes; }
+  const AddPrefixArray& AddPrefixes() const { return mAddPrefixes; }
+  const AddCompleteArray& AddCompletes() const { return mAddCompletes; }
+  const SubPrefixArray& SubPrefixes() const { return mSubPrefixes; }
+  const SubCompleteArray& SubCompletes() const { return mSubCompletes; }
 
   // =======
   // Updates
   // =======
   // Begin the update process.  Reads the store into memory.
   nsresult BeginUpdate();
 
   // Imports the data from a TableUpdate.
--- a/toolkit/components/url-classifier/LookupCache.cpp
+++ b/toolkit/components/url-classifier/LookupCache.cpp
@@ -166,28 +166,27 @@ LookupCache::Reset()
 
   Clear();
 
   return NS_OK;
 }
 
 
 nsresult
-LookupCache::Build(AddPrefixArray& aAddPrefixes,
-                   AddCompleteArray& aAddCompletes)
+LookupCache::Build(const AddPrefixArray& aAddPrefixes,
+                   const AddCompleteArray& aAddCompletes)
 {
   Telemetry::Accumulate(Telemetry::URLCLASSIFIER_LC_COMPLETIONS,
                         static_cast<PRUint32>(aAddCompletes.Length()));
 
   mCompletions.Clear();
   mCompletions.SetCapacity(aAddCompletes.Length());
   for (uint32 i = 0; i < aAddCompletes.Length(); i++) {
     mCompletions.AppendElement(aAddCompletes[i].CompleteHash());
   }
-  aAddCompletes.Clear();
   mCompletions.Sort();
 
   Telemetry::Accumulate(Telemetry::URLCLASSIFIER_LC_PREFIXES,
                         static_cast<PRUint32>(aAddPrefixes.Length()));
 
   nsresult rv = ConstructPrefixSet(aAddPrefixes);
   NS_ENSURE_SUCCESS(rv, rv);
   mPrimed = true;
@@ -675,32 +674,32 @@ LookupCache::GetHostKeys(const nsACStrin
 }
 
 bool LookupCache::IsPrimed()
 {
   return mPrimed;
 }
 
 nsresult
-LookupCache::ConstructPrefixSet(AddPrefixArray& aAddPrefixes)
+LookupCache::ConstructPrefixSet(const AddPrefixArray& aAddPrefixes)
 {
   Telemetry::AutoTimer<Telemetry::URLCLASSIFIER_PS_CONSTRUCT_TIME> timer;
 
   FallibleTArray<PRUint32> array;
   nsresult rv;
   if (!array.SetCapacity(aAddPrefixes.Length())) {
     rv = NS_ERROR_OUT_OF_MEMORY;
     goto error_bailout;
   }
 
   for (uint32 i = 0; i < aAddPrefixes.Length(); i++) {
     array.AppendElement(aAddPrefixes[i].PrefixHash().ToUint32());
   }
-  aAddPrefixes.Clear();
 
+  // clear old tree
   if (array.IsEmpty()) {
     // DB is empty, but put a sentinel to show that we looked
     array.AppendElement(0);
   }
   // PrefixSet requires sorted order
   array.Sort();
 
   // construct new one, replace old entries
--- a/toolkit/components/url-classifier/LookupCache.h
+++ b/toolkit/components/url-classifier/LookupCache.h
@@ -132,19 +132,18 @@ public:
 
   LookupCache(const nsACString& aTableName, nsIFile* aStoreFile);
   ~LookupCache();
 
   const nsCString &TableName() const { return mTableName; }
 
   nsresult Init();
   nsresult Open();
-  // This will Clear() the passed arrays when done.
-  nsresult Build(AddPrefixArray& aAddPrefixes,
-                 AddCompleteArray& aAddCompletes);
+  nsresult Build(const AddPrefixArray& aAddPrefixes,
+                 const AddCompleteArray& aAddCompletes);
   nsresult GetPrefixes(nsTArray<PRUint32>* aAddPrefixes);
 
 #if DEBUG && defined(PR_LOGGING)
   void Dump();
 #endif
   nsresult WriteFile();
   nsresult Has(const Completion& aCompletion,
                const Completion& aHostkey,
@@ -156,20 +155,19 @@ public:
 private:
 
   void Clear();
   nsresult Reset();
   void UpdateHeader();
   nsresult ReadHeader();
   nsresult EnsureSizeConsistent();
   nsresult ReadCompletions();
+  // Construct a Prefix Set with known prefixes
   nsresult LoadPrefixSet();
-  // Construct a Prefix Set with known prefixes.
-  // This will Clear() aAddPrefixes when done.
-  nsresult ConstructPrefixSet(AddPrefixArray& aAddPrefixes);
+  nsresult ConstructPrefixSet(const AddPrefixArray& aAddPrefixes);
 
   struct Header {
     uint32 magic;
     uint32 version;
     uint32 numCompletions;
   };
   Header mHeader;