Commit 146858a2 authored by Simon Giesecke's avatar Simon Giesecke
Browse files

Bug 708901 - Migrate to nsTHashSet in startupcache. r=dthayer

Depends on D109325

Differential Revision: https://phabricator.services.mozilla.com/D109326
parent 022093b8
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -858,16 +858,14 @@ bool StartupCacheDebugOutputStream::CheckReferences(nsISupports* aObject) {
  NS_ENSURE_SUCCESS(rv, false);
  if (flags & nsIClassInfo::SINGLETON) return true;

  nsISupportsHashKey* key = mObjectMap->GetEntry(aObject);
  if (key) {
  bool inserted = mObjectMap->EnsureInserted(aObject);
  if (!inserted) {
    NS_ERROR(
        "non-singleton aObject is referenced multiple times in this"
        "serialization, we don't support that.");
    return false;
  }

  mObjectMap->PutEntry(aObject);
  return true;
  return inserted;
}

// nsIObjectOutputStream implementation
+4 −3
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
#include "nsClassHashtable.h"
#include "nsComponentManagerUtils.h"
#include "nsTArray.h"
#include "nsTHashSet.h"
#include "nsTStringHasher.h"  // mozilla::DefaultHasher<nsCString>
#include "nsZipArchive.h"
#include "nsITimer.h"
@@ -235,7 +236,7 @@ class StartupCache : public nsIMemoryReporter {
  PRThread* mPrefetchThread;
  UniquePtr<Compression::LZ4FrameDecompressionContext> mDecompressionContext;
#ifdef DEBUG
  nsTHashtable<nsISupportsHashKey> mWriteObjectMap;
  nsTHashSet<nsCOMPtr<nsISupports>> mWriteObjectMap;
#endif
};

@@ -250,7 +251,7 @@ class StartupCacheDebugOutputStream final : public nsIObjectOutputStream {
  NS_DECL_NSIOBJECTOUTPUTSTREAM

  StartupCacheDebugOutputStream(nsIObjectOutputStream* binaryStream,
                                nsTHashtable<nsISupportsHashKey>* objectMap)
                                nsTHashSet<nsCOMPtr<nsISupports>>* objectMap)
      : mBinaryStream(binaryStream), mObjectMap(objectMap) {}

  NS_FORWARD_SAFE_NSIBINARYOUTPUTSTREAM(mBinaryStream)
@@ -259,7 +260,7 @@ class StartupCacheDebugOutputStream final : public nsIObjectOutputStream {
  bool CheckReferences(nsISupports* aObject);

  nsCOMPtr<nsIObjectOutputStream> mBinaryStream;
  nsTHashtable<nsISupportsHashKey>* mObjectMap;
  nsTHashSet<nsCOMPtr<nsISupports>>* mObjectMap;
};
#endif  // DEBUG