Bug 997963, part 2 - Allocate bundleCacheEntry_t using new and free. r=ehsan
authorAndrew McCreight <continuation@gmail.com>
Mon, 21 Apr 2014 09:41:56 -0700
changeset 179405 d5f5047b958510c1002fd34c1c9d227429ff29c0
parent 179404 a61517ca13ace8eace698c9066be62131ccef0fb
child 179406 29173518f045ec4da474a50c6c2b6e7f08d87638
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersehsan
bugs997963
milestone31.0a1
Bug 997963, part 2 - Allocate bundleCacheEntry_t using new and free. r=ehsan
intl/strres/src/nsStringBundle.cpp
intl/strres/src/nsStringBundleService.h
--- a/intl/strres/src/nsStringBundle.cpp
+++ b/intl/strres/src/nsStringBundle.cpp
@@ -496,34 +496,28 @@ struct bundleCacheEntry_t : public Linke
 
 nsStringBundleService::nsStringBundleService() :
   mBundleMap(MAX_CACHED_BUNDLES, true)
 {
 #ifdef DEBUG_tao_
   printf("\n++ nsStringBundleService::nsStringBundleService ++\n");
 #endif
 
-  PL_InitArenaPool(&mCacheEntryPool, "srEntries",
-                   sizeof(bundleCacheEntry_t)*MAX_CACHED_BUNDLES,
-                   sizeof(bundleCacheEntry_t));
-
   mErrorService = do_GetService(kErrorServiceCID);
   NS_ASSERTION(mErrorService, "Couldn't get error service");
-
 }
 
 NS_IMPL_ISUPPORTS3(nsStringBundleService,
                    nsIStringBundleService,
                    nsIObserver,
                    nsISupportsWeakReference)
 
 nsStringBundleService::~nsStringBundleService()
 {
   flushBundleCache();
-  PL_FinishArenaPool(&mCacheEntryPool);
 }
 
 nsresult
 nsStringBundleService::Init()
 {
   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
   if (os) {
     os->AddObserver(this, "memory-pressure", true);
@@ -563,20 +557,19 @@ nsStringBundleService::Observe(nsISuppor
 void
 nsStringBundleService::flushBundleCache()
 {
   // release all bundles in the cache
   mBundleMap.Reset();
 
   while (!mBundleCache.isEmpty()) {
     bundleCacheEntry_t *cacheEntry = mBundleCache.popFirst();
-
     recycleEntry(cacheEntry);
+    delete cacheEntry;
   }
-  PL_FreeArenaPool(&mCacheEntryPool);
 }
 
 NS_IMETHODIMP
 nsStringBundleService::FlushBundles()
 {
   flushBundleCache();
   return NS_OK;
 }
@@ -623,21 +616,17 @@ nsStringBundleService::getStringBundle(c
 bundleCacheEntry_t *
 nsStringBundleService::insertIntoCache(nsIStringBundle* aBundle,
                                        nsCStringKey* aHashKey)
 {
   bundleCacheEntry_t *cacheEntry;
 
   if (mBundleMap.Count() < MAX_CACHED_BUNDLES) {
     // cache not full - create a new entry
-
-    void *cacheEntryArena;
-    PL_ARENA_ALLOCATE(cacheEntryArena, &mCacheEntryPool, sizeof(bundleCacheEntry_t));
-    cacheEntry = new (cacheEntryArena) bundleCacheEntry_t();
-
+    cacheEntry = new bundleCacheEntry_t();
   } else {
     // cache is full
     // take the last entry in the list, and recycle it.
     cacheEntry = mBundleCache.getLast();
 
     // remove it from the hash table and linked list
     NS_ASSERTION(mBundleMap.Exists(cacheEntry->mHashKey),
                  "Element will not be removed!");
--- a/intl/strres/src/nsStringBundleService.h
+++ b/intl/strres/src/nsStringBundleService.h
@@ -1,18 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsStringBundleService_h__
 #define nsStringBundleService_h__
 
-#include "plarena.h"
-
 #include "nsCOMPtr.h"
 #include "nsHashtable.h"
 #include "nsIPersistentProperties2.h"
 #include "nsIStringBundle.h"
 #include "nsIObserver.h"
 #include "nsWeakReference.h"
 #include "nsIErrorService.h"
 #include "nsIStringBundleOverride.h"
@@ -45,15 +43,14 @@ private:
 
   bundleCacheEntry_t *insertIntoCache(nsIStringBundle *aBundle,
                                       nsCStringKey *aHashKey);
 
   static void recycleEntry(bundleCacheEntry_t*);
 
   nsHashtable mBundleMap;
   mozilla::LinkedList<bundleCacheEntry_t> mBundleCache;
-  PLArenaPool mCacheEntryPool;
 
   nsCOMPtr<nsIErrorService>     mErrorService;
   nsCOMPtr<nsIStringBundleOverride> mOverrideStrings;
 };
 
 #endif