Commit b8fb1105 authored by Santiago Gimeno's avatar Santiago Gimeno
Browse files

Bug 713416 - Remove nsUniCharEntry class and replace it with nsUnicharPtrHashKey; r=khuey,ehsan

parent 7e84b6a5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ NS_IMETHODIMP mozPersonalDictionary::Load()
// This is not threadsafe, and only safe if the consumer does not 
// modify the list.
static PLDHashOperator
AddHostToStringArray(nsUniCharEntry *aEntry, void *aArg)
AddHostToStringArray(nsUnicharPtrHashKey *aEntry, void *aArg)
{
  static_cast<nsTArray<nsString>*>(aArg)->AppendElement(nsDependentString(aEntry->GetKey()));
  return PL_DHASH_NEXT;
+4 −35
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@
#include "nsTHashtable.h"
#include "nsCRT.h"
#include "nsCycleCollectionParticipant.h"
#include "nsHashKeys.h"

#define MOZ_PERSONALDICTIONARY_CONTRACTID "@mozilla.org/spellchecker/personaldictionary;1"
#define MOZ_PERSONALDICTIONARY_CID         \
@@ -55,38 +56,6 @@
0X7EF52EAF, 0XB7E1, 0X462B, \
  { 0X87, 0XE2, 0X5D, 0X1D, 0XBA, 0XCA, 0X90, 0X48 } }

class nsUniCharEntry : public PLDHashEntryHdr
{
public:
  // Hash methods
  typedef const PRUnichar* KeyType;
  typedef const PRUnichar* KeyTypePointer;

  nsUniCharEntry(const PRUnichar* aKey) : mKey(nsCRT::strdup(aKey)) {}
  nsUniCharEntry(const nsUniCharEntry& toCopy)
  { 
    NS_NOTREACHED("ALLOW_MEMMOVE is set, so copy ctor shouldn't be called");
  }

  ~nsUniCharEntry()
  { 
    if (mKey)
      nsCRT::free(mKey);
  }
 
  KeyType GetKey() const { return mKey; }
  bool KeyEquals(KeyTypePointer aKey) const { return !nsCRT::strcmp(mKey, aKey); }
  static KeyTypePointer KeyToPointer(KeyType aKey) { return aKey; }

  static PLDHashNumber HashKey(KeyTypePointer aKey) { return nsCRT::HashCode(aKey); }

  enum { ALLOW_MEMMOVE = true };

private:
  PRUnichar *mKey;
};


class mozPersonalDictionary : public mozIPersonalDictionary,
                              public nsIObserver,
                              public nsSupportsWeakReference
@@ -104,8 +73,8 @@ public:

protected:
  bool           mDirty;       /* has the dictionary been modified */
  nsTHashtable<nsUniCharEntry> mDictionaryTable;
  nsTHashtable<nsUniCharEntry> mIgnoreTable;
  nsTHashtable<nsUnicharPtrHashKey> mDictionaryTable;
  nsTHashtable<nsUnicharPtrHashKey> mIgnoreTable;
  nsCOMPtr<nsIUnicodeEncoder>  mEncoder; /*Encoder to use to compare with spellchecker word */
};