Use flat strings when constructing string keys. This fixes a few high volume string key constructors. See 135781. r=dp@netscape.com, sr=darin@netscape.com

This commit is contained in:
dougt%netscape.com 2002-04-15 22:39:43 +00:00
Родитель cfa91392a7
Коммит f4cf458eb8
6 изменённых файлов: 38 добавлений и 17 удалений

Просмотреть файл

@ -152,7 +152,8 @@ void NS_NameSpaceManagerShutdown()
static PRInt32 FindNameSpaceID(const nsAString& aURI)
{
NS_ASSERTION(nsnull != gURIToIDTable, "no URI table");
nsStringKey key(aURI);
const nsPromiseFlatString& flatString = PromiseFlatString(aURI);
nsStringKey key(flatString);
void* value = gURIToIDTable->Get(&key);
if (nsnull != value) {
return NS_PTR_TO_INT32(value);

Просмотреть файл

@ -771,7 +771,8 @@ nsEventListenerManager::AddEventListenerByType(nsIDOMEventListener *aListener,
AddEventListener(aListener, arrayType, subType, nsnull, aFlags);
}
else {
nsStringKey key(aType);
const nsPromiseFlatString& flatString = PromiseFlatString(aType);
nsStringKey key(flatString);
AddEventListener(aListener, eEventArrayType_Hash, NS_EVENT_BITS_NONE, &key, aFlags);
}
@ -792,7 +793,8 @@ nsEventListenerManager::RemoveEventListenerByType(nsIDOMEventListener *aListener
RemoveEventListener(aListener, arrayType, subType, nsnull, aFlags);
}
else {
nsStringKey key(aType);
const nsPromiseFlatString& flatString = PromiseFlatString(aType);
nsStringKey key(flatString);
RemoveEventListener(aListener, eEventArrayType_Hash, NS_EVENT_BITS_NONE, &key, aFlags);
}

Просмотреть файл

@ -66,7 +66,8 @@ NS_IMPL_ISUPPORTS2(nsControllerCommandManager, nsIControllerCommandManager, nsIS
NS_IMETHODIMP
nsControllerCommandManager::RegisterCommand(const nsAString & aCommandName, nsIControllerCommand *aCommand)
{
nsStringKey commandKey(aCommandName);
const nsPromiseFlatString& flatString = PromiseFlatString(aCommandName);
nsStringKey commandKey(flatString);
if (mCommandsTable.Put (&commandKey, aCommand))
{
@ -79,11 +80,13 @@ nsControllerCommandManager::RegisterCommand(const nsAString & aCommandName, nsIC
return NS_OK;
}
#error
NS_IMETHODIMP
nsControllerCommandManager::UnregisterCommand(const nsAString & aCommandName, nsIControllerCommand *aCommand)
{
nsStringKey commandKey(aCommandName);
const nsPromiseFlatString& flatString = PromiseFlatString(aName);
nsStringKey commandKey(flatString);
PRBool any_object_actually_removed_p = mCommandsTable.Remove (&commandKey);
return any_object_actually_removed_p? NS_OK : NS_ERROR_FAILURE;
@ -97,7 +100,8 @@ nsControllerCommandManager::FindCommandHandler(const nsAString & aCommandName, n
*outCommand = NULL;
nsStringKey commandKey(aCommandName);
const nsPromiseFlatString& flatString = PromiseFlatString(aCommandName);
nsStringKey commandKey(flatString);
nsISupports* foundCommand = mCommandsTable.Get(&commandKey); // this does the addref
if (!foundCommand) return NS_ERROR_FAILURE;

Просмотреть файл

@ -66,7 +66,8 @@ nsPresState::GetStateProperty(const nsAString& aName,
// Retrieve from hashtable.
if (mPropertyTable) {
nsStringKey key(aName);
const nsPromiseFlatString& flatString = PromiseFlatString(aName);
nsStringKey key(flatString);
nsCOMPtr<nsISupportsString> supportsStr =
dont_AddRef(NS_STATIC_CAST(nsISupportsString*,
@ -92,7 +93,8 @@ nsPresState::SetStateProperty(const nsAString& aName, const nsAString& aValue)
}
// Add to hashtable
nsStringKey key(aName);
const nsPromiseFlatString& flatString = PromiseFlatString(aName);
nsStringKey key(flatString);
nsCOMPtr<nsISupportsString> supportsStr(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
NS_ENSURE_TRUE(supportsStr, NS_ERROR_OUT_OF_MEMORY);
@ -109,7 +111,8 @@ nsPresState::RemoveStateProperty(const nsAString& aName)
if (!mPropertyTable)
return NS_OK;
nsStringKey key(aName);
const nsPromiseFlatString& flatString = PromiseFlatString(aName);
nsStringKey key(flatString);
mPropertyTable->Remove(&key);
return NS_OK;
@ -122,7 +125,8 @@ nsPresState::GetStatePropertyAsSupports(const nsAString& aName, nsISupports** aR
nsCOMPtr<nsISupports> supp;
if (mPropertyTable) {
nsStringKey key(aName);
const nsPromiseFlatString& flatString = PromiseFlatString(aName);
nsStringKey key(flatString);
supp = dont_AddRef(NS_STATIC_CAST(nsISupports*, mPropertyTable->Get(&key)));
}
@ -140,7 +144,9 @@ nsPresState::SetStatePropertyAsSupports(const nsAString& aName, nsISupports* aVa
}
// Add to hashtable
nsStringKey key(aName);
const nsPromiseFlatString& flatString = PromiseFlatString(aName);
nsStringKey key(flatString);
mPropertyTable->Put(&key, aValue);
return NS_OK;
}

Просмотреть файл

@ -66,7 +66,8 @@ nsPresState::GetStateProperty(const nsAString& aName,
// Retrieve from hashtable.
if (mPropertyTable) {
nsStringKey key(aName);
const nsPromiseFlatString& flatString = PromiseFlatString(aName);
nsStringKey key(flatString);
nsCOMPtr<nsISupportsString> supportsStr =
dont_AddRef(NS_STATIC_CAST(nsISupportsString*,
@ -92,7 +93,8 @@ nsPresState::SetStateProperty(const nsAString& aName, const nsAString& aValue)
}
// Add to hashtable
nsStringKey key(aName);
const nsPromiseFlatString& flatString = PromiseFlatString(aName);
nsStringKey key(flatString);
nsCOMPtr<nsISupportsString> supportsStr(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
NS_ENSURE_TRUE(supportsStr, NS_ERROR_OUT_OF_MEMORY);
@ -109,7 +111,8 @@ nsPresState::RemoveStateProperty(const nsAString& aName)
if (!mPropertyTable)
return NS_OK;
nsStringKey key(aName);
const nsPromiseFlatString& flatString = PromiseFlatString(aName);
nsStringKey key(flatString);
mPropertyTable->Remove(&key);
return NS_OK;
@ -122,7 +125,8 @@ nsPresState::GetStatePropertyAsSupports(const nsAString& aName, nsISupports** aR
nsCOMPtr<nsISupports> supp;
if (mPropertyTable) {
nsStringKey key(aName);
const nsPromiseFlatString& flatString = PromiseFlatString(aName);
nsStringKey key(flatString);
supp = dont_AddRef(NS_STATIC_CAST(nsISupports*, mPropertyTable->Get(&key)));
}
@ -140,7 +144,9 @@ nsPresState::SetStatePropertyAsSupports(const nsAString& aName, nsISupports* aVa
}
// Add to hashtable
nsStringKey key(aName);
const nsPromiseFlatString& flatString = PromiseFlatString(aName);
nsStringKey key(flatString);
mPropertyTable->Put(&key, aValue);
return NS_OK;
}

Просмотреть файл

@ -96,7 +96,9 @@ inline PRInt32
LookupLowercasedKeyword(const nsACString& aLowercasedKeyword,
nsHashtable* aTable)
{
nsCStringKey key(aLowercasedKeyword);
const nsPromiseFlatCString& flatString = PromiseFlatCString(aLowercasedKeyword);
nsCStringKey key(flatString);
void* val = aTable->Get(&key);
return val ? NS_PTR_TO_INT32(val) - 1 :
nsStaticCaseInsensitiveNameTable::NOT_FOUND;