Bug 1257402 - Remove NS_NewPermanentAtom() and nsIAtomService.getPermanentAtom(). r=froydnj,kmag.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 17 Mar 2016 13:11:31 +1100
changeset 290194 80beb85ac554595b38a13825d35c680a06eb0656
parent 290193 e139011ede5bda9f57c356cdc9e69e637680d671
child 290195 3c332cbe9fc7776a19dfd9851482ab5d86a0ade2
push id30114
push usercbook@mozilla.com
push dateThu, 24 Mar 2016 15:15:54 +0000
treeherdermozilla-central@24c5fbde4488 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, kmag
bugs1257402
milestone48.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 1257402 - Remove NS_NewPermanentAtom() and nsIAtomService.getPermanentAtom(). r=froydnj,kmag. The former is only used inconsequentially in tests. The second is not used at all.
gfx/tests/gtest/gfxFontSelectionTests.h
gfx/tests/gtest/gfxTextRunPerfTest.cpp
gfx/tests/gtest/gfxWordCacheTest.cpp
xpcom/ds/nsAtomService.cpp
xpcom/ds/nsAtomTable.cpp
xpcom/ds/nsIAtom.idl
xpcom/ds/nsIAtomService.idl
xpcom/tests/gtest/TestAtoms.cpp
--- a/gfx/tests/gtest/gfxFontSelectionTests.h
+++ b/gfx/tests/gtest/gfxFontSelectionTests.h
@@ -72,26 +72,26 @@ SetupTests(nsTArray<TestEntry>& testList
 {
     TestEntry *t;
 
     /* some common styles */
     gfxFontStyle style_western_normal_16 (mozilla::gfx::FontStyle::NORMAL,
                                           400,
                                           0,
                                           16.0,
-                                          NS_NewPermanentAtom(NS_LITERAL_STRING("en")),
+                                          NS_NewAtom(NS_LITERAL_STRING("en")),
                                           0.0,
                                           false, false,
                                           NS_LITERAL_STRING(""));
 
     gfxFontStyle style_western_bold_16 (mozilla::gfx::FontStyle::NORMAL,
                                         700,
                                         0,
                                         16.0,
-                                        NS_NewPermanentAtom(NS_LITERAL_STRING("en")),
+                                        NS_NewAtom(NS_LITERAL_STRING("en")),
                                         0.0,
                                         false, false,
                                         NS_LITERAL_STRING(""));
 
     /* Test 0 */
     t = AddTest (testList, "sans-serif",
                  style_western_normal_16,
                  S_ASCII,
--- a/gfx/tests/gtest/gfxTextRunPerfTest.cpp
+++ b/gfx/tests/gtest/gfxTextRunPerfTest.cpp
@@ -53,17 +53,17 @@ const char* lastFamilies = nullptr;
 static void
 RunTest (TestEntry *test, gfxContext *ctx) {
     RefPtr<gfxFontGroup> fontGroup;
     if (!lastFamilies || strcmp(lastFamilies, test->mFamilies)) {
         gfxFontStyle style_western_normal_16 (mozilla::gfx::FontStyle::NORMAL,
                                               400,
                                               0,
                                               16.0,
-                                              NS_NewPermanentAtom(NS_LITERAL_STRING("en")),
+                                              NS_NewAtom(NS_LITERAL_STRING("en")),
                                               0.0,
                                               false, false,
                                               NS_LITERAL_STRING(""));
 
         fontGroup = gfxPlatform::GetPlatform()->CreateFontGroup(NS_ConvertUTF8toUTF16(test->mFamilies), &style_western_normal_16, nullptr, nullptr, 1.0);
     }
 
     nsAutoPtr<gfxTextRun> textRun;
--- a/gfx/tests/gtest/gfxWordCacheTest.cpp
+++ b/gfx/tests/gtest/gfxWordCacheTest.cpp
@@ -96,17 +96,17 @@ TEST(Gfx, WordCache) {
   gTextRuns = new FrameTextRunCache();
 
   RefPtr<DrawTarget> dt = MakeDrawTarget();
   {
     gfxFontStyle style(mozilla::gfx::FontStyle::NORMAL,
                        139,
                        10.0,
                        0,
-                       NS_NewPermanentAtom(NS_LITERAL_STRING("en")),
+                       NS_NewAtom(NS_LITERAL_STRING("en")),
                        0.0,
                        false, false,
                        NS_LITERAL_STRING(""));
 
     RefPtr<gfxFontGroup> fontGroup =
       gfxPlatform::GetPlatform()->CreateFontGroup(
         NS_LITERAL_STRING("Geneva, MS Sans Serif, Helvetica,serif"), &style,
         nullptr, nullptr, 1.0);
--- a/xpcom/ds/nsAtomService.cpp
+++ b/xpcom/ds/nsAtomService.cpp
@@ -18,19 +18,8 @@ nsAtomService::GetAtom(const nsAString& 
 {
   *aResult = NS_NewAtom(aString).take();
   if (!*aResult) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   return NS_OK;
 }
-
-nsresult
-nsAtomService::GetPermanentAtom(const nsAString& aString, nsIAtom** aResult)
-{
-  *aResult = NS_NewPermanentAtom(aString);
-  if (!*aResult) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
-  return NS_OK;
-}
--- a/xpcom/ds/nsAtomTable.cpp
+++ b/xpcom/ds/nsAtomTable.cpp
@@ -668,38 +668,16 @@ NS_NewAtom(const nsAString& aUTF16String
   }
 
   RefPtr<AtomImpl> atom = new AtomImpl(aUTF16String, hash);
   he->mAtom = atom;
 
   return atom.forget();
 }
 
-nsIAtom*
-NS_NewPermanentAtom(const nsAString& aUTF16String)
-{
-  uint32_t hash;
-  AtomTableEntry* he = GetAtomHashEntry(aUTF16String.Data(),
-                                        aUTF16String.Length(),
-                                        &hash);
-
-  AtomImpl* atom = he->mAtom;
-  if (atom) {
-    if (!atom->IsPermanent()) {
-      PromoteToPermanent(atom);
-    }
-  } else {
-    atom = new PermanentAtomImpl(aUTF16String, hash);
-    he->mAtom = atom;
-  }
-
-  // No need to addref since permanent atoms aren't refcounted anyway
-  return atom;
-}
-
 nsrefcnt
 NS_GetNumberOfAtoms(void)
 {
   MOZ_ASSERT(gAtomTable);
   return gAtomTable->EntryCount();
 }
 
 nsIAtom*
--- a/xpcom/ds/nsIAtom.idl
+++ b/xpcom/ds/nsIAtom.idl
@@ -85,23 +85,16 @@ protected:
 %{C++
 /*
  * The three forms of NS_NewAtom and do_GetAtom (for use with
  * |nsCOMPtr<nsIAtom>|) return the atom for the string given.  At any
  * given time there will always be one atom representing a given string.
  * Atoms are intended to make string comparison cheaper by simplifying
  * it to pointer equality.  A pointer to the atom that does not own a
  * reference is not guaranteed to be valid.
- *
- * The three forms of NS_NewPermanentAtom and do_GetPermanentAtom return
- * the atom for the given string and ensure that the atom is permanent.
- * An atom that is permanent will exist (occupy space at a specific
- * location in memory) until XPCOM is shut down.  The advantage of
- * permanent atoms is that they do not need to maintain a reference
- * count, which requires locking and hurts performance.
  */
 
 
 /**
  * Find an atom that matches the given UTF-8 string.
  * The string is assumed to be zero terminated.  Never returns null.
  */
 extern already_AddRefed<nsIAtom> NS_NewAtom(const char* aUTF8String);
@@ -123,17 +116,16 @@ inline already_AddRefed<nsIAtom> do_GetA
 extern already_AddRefed<nsIAtom> NS_NewAtom(const char16_t* aUTF16String);
 inline already_AddRefed<nsIAtom> do_GetAtom(const char16_t* aUTF16String)
     { return NS_NewAtom(aUTF16String); }
 
 /**
  * Find an atom that matches the given UTF-16 string.  Never returns null.
  */
 extern already_AddRefed<nsIAtom> NS_NewAtom(const nsAString& aUTF16String);
-extern nsIAtom* NS_NewPermanentAtom(const nsAString& aUTF16String);
 inline already_AddRefed<nsIAtom> do_GetAtom(const nsAString& aUTF16String)
     { return NS_NewAtom(aUTF16String); }
 
 /**
  * Return a count of the total number of atoms currently
  * alive in the system.
  */
 extern nsrefcnt NS_GetNumberOfAtoms(void);
--- a/xpcom/ds/nsIAtomService.idl
+++ b/xpcom/ds/nsIAtomService.idl
@@ -27,15 +27,9 @@ interface nsIAtom;
 [scriptable, uuid(9c1f50b9-f9eb-42d4-a8cb-2c7600aeb241)]
 interface nsIAtomService : nsISupports {
 
   /**
    * Version of NS_NewAtom that doesn't require linking against the
    * XPCOM library.  See nsIAtom.idl.
    */
   nsIAtom getAtom(in AString value);
-
-  /**
-   * Version of NS_NewPermanentAtom that doesn't require linking against
-   * the XPCOM library.  See nsIAtom.idl.
-   */
-  nsIAtom getPermanentAtom(in AString value);
 };
--- a/xpcom/tests/gtest/TestAtoms.cpp
+++ b/xpcom/tests/gtest/TestAtoms.cpp
@@ -170,41 +170,9 @@ TEST(Atoms, Table)
   EXPECT_TRUE(isStaticAtom(sAtom2));
   EXPECT_TRUE(sAtom3);
   EXPECT_TRUE(sAtom3->Equals(NS_LITERAL_STRING(THIRD_ATOM_STR)));
   EXPECT_TRUE(isStaticAtom(sAtom3));
   EXPECT_EQ(NS_GetNumberOfAtoms(), count + 3);
   EXPECT_EQ(thirdNonPerm, sAtom3);
 }
 
-#define FIRST_PERM_ATOM_STR "first permanent atom. Hello!"
-#define SECOND_PERM_ATOM_STR "second permanent atom. @World!"
-
-TEST(Atoms, Permanent)
-{
-  nsrefcnt count = NS_GetNumberOfAtoms();
-
-  {
-    nsCOMPtr<nsIAtom> first = do_GetAtom(FIRST_PERM_ATOM_STR);
-    EXPECT_TRUE(first->Equals(NS_LITERAL_STRING(FIRST_PERM_ATOM_STR)));
-    EXPECT_FALSE(isStaticAtom(first));
-
-    nsCOMPtr<nsIAtom> first_p =
-      NS_NewPermanentAtom(NS_LITERAL_STRING(FIRST_PERM_ATOM_STR));
-    EXPECT_TRUE(first_p->Equals(NS_LITERAL_STRING(FIRST_PERM_ATOM_STR)));
-    EXPECT_TRUE(isStaticAtom(first_p));
-    EXPECT_EQ(first, first_p);
-
-    nsCOMPtr<nsIAtom> second_p =
-      NS_NewPermanentAtom(NS_LITERAL_STRING(SECOND_PERM_ATOM_STR));
-    EXPECT_TRUE(second_p->Equals(NS_LITERAL_STRING(SECOND_PERM_ATOM_STR)));
-    EXPECT_TRUE(isStaticAtom(second_p));
-
-    nsCOMPtr<nsIAtom> second = do_GetAtom(SECOND_PERM_ATOM_STR);
-    EXPECT_TRUE(second->Equals(NS_LITERAL_STRING(SECOND_PERM_ATOM_STR)));
-    EXPECT_TRUE(isStaticAtom(second));
-    EXPECT_EQ(second, second_p);
-  }
-
-  EXPECT_EQ(NS_GetNumberOfAtoms(), count + 2);
 }
-
-}