mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-11 10:08:41 +00:00
Make ns[C]StringKey cooperate better with new string classes (although it doesn't participate in sharing). When created (non-cloned) from a flat string it will be dependent (as it was when created from ns[C]String), but it will copy non-flat strings.
This commit is contained in:
parent
9a358b6df4
commit
5abb921f98
@ -33,6 +33,7 @@
|
||||
#include "prmem.h"
|
||||
#include "prlog.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// These functions really should be part of nspr, and have internal knowledge
|
||||
@ -390,8 +391,22 @@ void nsHashtable::Reset(nsHashtableEnumFunc destroyFunc, void* closure)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsCStringKey::nsCStringKey(const nsCString& str)
|
||||
: mStr((char*)str.get()), mStrLen(str.Length()), mOwnership(OWN_CLONE)
|
||||
nsCStringKey::nsCStringKey(const nsAFlatCString& str)
|
||||
: mStr(NS_CONST_CAST(char*, str.get())),
|
||||
mStrLen(str.Length()),
|
||||
mOwnership(OWN_CLONE)
|
||||
{
|
||||
NS_ASSERTION(mStr, "null string key");
|
||||
#ifdef DEBUG
|
||||
mKeyType = CStringKey;
|
||||
#endif
|
||||
MOZ_COUNT_CTOR(nsCStringKey);
|
||||
}
|
||||
|
||||
nsCStringKey::nsCStringKey(const nsACString& str)
|
||||
: mStr(ToNewCString(str)),
|
||||
mStrLen(str.Length()),
|
||||
mOwnership(OWN)
|
||||
{
|
||||
NS_ASSERTION(mStr, "null string key");
|
||||
#ifdef DEBUG
|
||||
@ -456,8 +471,22 @@ nsCStringKey::Clone() const
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsStringKey::nsStringKey(const nsAReadableString& str)
|
||||
: mStr(NS_CONST_CAST(PRUnichar*, NS_STATIC_CAST(const PRUnichar *, PromiseFlatString(str).get()))), mStrLen(str.Length()), mOwnership(OWN_CLONE)
|
||||
nsStringKey::nsStringKey(const nsAFlatString& str)
|
||||
: mStr(NS_CONST_CAST(PRUnichar*, str.get())),
|
||||
mStrLen(str.Length()),
|
||||
mOwnership(OWN_CLONE)
|
||||
{
|
||||
NS_ASSERTION(mStr, "null string key");
|
||||
#ifdef DEBUG
|
||||
mKeyType = StringKey;
|
||||
#endif
|
||||
MOZ_COUNT_CTOR(nsStringKey);
|
||||
}
|
||||
|
||||
nsStringKey::nsStringKey(const nsAString& str)
|
||||
: mStr(ToNewUnicode(str)),
|
||||
mStrLen(str.Length()),
|
||||
mOwnership(OWN)
|
||||
{
|
||||
NS_ASSERTION(mStr, "null string key");
|
||||
#ifdef DEBUG
|
||||
|
@ -277,7 +277,8 @@ public:
|
||||
};
|
||||
|
||||
nsCStringKey(const char* str, PRInt32 strLen = -1, Ownership own = OWN_CLONE);
|
||||
nsCStringKey(const nsCString& str);
|
||||
nsCStringKey(const nsAFlatCString& str);
|
||||
nsCStringKey(const nsACString& str);
|
||||
~nsCStringKey(void);
|
||||
|
||||
PRUint32 HashCode(void) const;
|
||||
@ -306,7 +307,8 @@ public:
|
||||
};
|
||||
|
||||
nsStringKey(const PRUnichar* str, PRInt32 strLen = -1, Ownership own = OWN_CLONE);
|
||||
nsStringKey(const nsAReadableString& str);
|
||||
nsStringKey(const nsAFlatString& str);
|
||||
nsStringKey(const nsAString& str);
|
||||
~nsStringKey(void);
|
||||
|
||||
PRUint32 HashCode(void) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user