From 65324a42a1604e3138a1ea506d39d52c914a195d Mon Sep 17 00:00:00 2001 From: Gian-Carlo Pascutto Date: Fri, 20 Apr 2012 07:46:46 +0200 Subject: [PATCH] Backout 35bf0d62cc30 (Bug 726002). rs=dcamp a=mfinkle --- toolkit/components/url-classifier/Classifier.cpp | 1 - toolkit/components/url-classifier/HashStore.h | 8 ++++---- toolkit/components/url-classifier/LookupCache.cpp | 9 ++++----- toolkit/components/url-classifier/LookupCache.h | 10 ++++------ 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/toolkit/components/url-classifier/Classifier.cpp b/toolkit/components/url-classifier/Classifier.cpp index a6ea8bc09d2..212c659fe04 100644 --- a/toolkit/components/url-classifier/Classifier.cpp +++ b/toolkit/components/url-classifier/Classifier.cpp @@ -531,7 +531,6 @@ Classifier::ApplyTableUpdates(nsTArray* aUpdates, NS_ENSURE_SUCCESS(rv, rv); rv = store->AugmentAdds(AddPrefixHashes); NS_ENSURE_SUCCESS(rv, rv); - AddPrefixHashes.Clear(); uint32 applied = 0; bool updateFreshness = false; diff --git a/toolkit/components/url-classifier/HashStore.h b/toolkit/components/url-classifier/HashStore.h index e832cb9e35b..fca2d2aa27c 100644 --- a/toolkit/components/url-classifier/HashStore.h +++ b/toolkit/components/url-classifier/HashStore.h @@ -120,10 +120,10 @@ public: 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 diff --git a/toolkit/components/url-classifier/LookupCache.cpp b/toolkit/components/url-classifier/LookupCache.cpp index ef70f7b568e..6763af41452 100644 --- a/toolkit/components/url-classifier/LookupCache.cpp +++ b/toolkit/components/url-classifier/LookupCache.cpp @@ -171,8 +171,8 @@ LookupCache::Reset() nsresult -LookupCache::Build(AddPrefixArray& aAddPrefixes, - AddCompleteArray& aAddCompletes) +LookupCache::Build(const AddPrefixArray& aAddPrefixes, + const AddCompleteArray& aAddCompletes) { Telemetry::Accumulate(Telemetry::URLCLASSIFIER_LC_COMPLETIONS, static_cast(aAddCompletes.Length())); @@ -182,7 +182,6 @@ LookupCache::Build(AddPrefixArray& aAddPrefixes, for (uint32 i = 0; i < aAddCompletes.Length(); i++) { mCompletions.AppendElement(aAddCompletes[i].CompleteHash()); } - aAddCompletes.Clear(); mCompletions.Sort(); Telemetry::Accumulate(Telemetry::URLCLASSIFIER_LC_PREFIXES, @@ -680,7 +679,7 @@ bool LookupCache::IsPrimed() } nsresult -LookupCache::ConstructPrefixSet(AddPrefixArray& aAddPrefixes) +LookupCache::ConstructPrefixSet(const AddPrefixArray& aAddPrefixes) { Telemetry::AutoTimer timer; @@ -694,8 +693,8 @@ LookupCache::ConstructPrefixSet(AddPrefixArray& aAddPrefixes) 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); diff --git a/toolkit/components/url-classifier/LookupCache.h b/toolkit/components/url-classifier/LookupCache.h index ba50701b1a9..5ba07d5fe09 100644 --- a/toolkit/components/url-classifier/LookupCache.h +++ b/toolkit/components/url-classifier/LookupCache.h @@ -137,9 +137,8 @@ public: 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* aAddPrefixes); #if DEBUG && defined(PR_LOGGING) @@ -161,10 +160,9 @@ private: 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;