зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1477579: Part 1 - Use literal strings for statically registered contract ID keys. r=froydnj
Most of our components are static, and registered using literal C strings. For those components, we currently use a nsDependentCString as a key when creating a hash entry, which leads to an unnecessary duplication. Using literal CStrings instead avoids the duplication. MozReview-Commit-ID: 5DOUF8ZQMlh --HG-- extra : source : 8359f8fe418419c50ab0ed93496e7445b570ba9f extra : absorb_source : 2a33ae4e7e6d312adcea8ece2158f07a7050e01e
This commit is contained in:
Родитель
d487539dd5
Коммит
b8f2198d8c
|
@ -57,6 +57,10 @@
|
|||
#include "mozilla/Logging.h"
|
||||
#include "LogModulePrefWatcher.h"
|
||||
|
||||
#ifdef MOZ_MEMORY
|
||||
#include "mozmemory.h"
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
static LazyLogModule nsComponentManagerLog("nsComponentManager");
|
||||
|
@ -468,6 +472,42 @@ ProcessSelectorMatches(Module::ProcessSelector aSelector)
|
|||
|
||||
static const int kModuleVersionWithSelector = 51;
|
||||
|
||||
template<typename T>
|
||||
static void
|
||||
AssertNotMallocAllocated(T* aPtr)
|
||||
{
|
||||
#if defined(DEBUG) && defined(MOZ_MEMORY)
|
||||
jemalloc_ptr_info_t info;
|
||||
jemalloc_ptr_info((void*)aPtr, &info);
|
||||
MOZ_ASSERT(info.tag == TagUnknown);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static void
|
||||
AssertNotStackAllocated(T* aPtr)
|
||||
{
|
||||
// The main thread's stack should be allocated at the top of our address
|
||||
// space. Anything stack allocated should be above us on the stack, and
|
||||
// therefore above our first argument pointer.
|
||||
// Only this is apparently not the case on Windows.
|
||||
#ifndef XP_WIN
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(uintptr_t(aPtr) < uintptr_t(&aPtr));
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline nsCString
|
||||
AsLiteralCString(const char* aStr)
|
||||
{
|
||||
AssertNotMallocAllocated(aStr);
|
||||
AssertNotStackAllocated(aStr);
|
||||
|
||||
nsCString str;
|
||||
str.AssignLiteral(aStr, strlen(aStr));
|
||||
return str;
|
||||
}
|
||||
|
||||
void
|
||||
nsComponentManagerImpl::RegisterModule(const mozilla::Module* aModule,
|
||||
FileLocation* aFile)
|
||||
|
@ -583,7 +623,7 @@ nsComponentManagerImpl::RegisterContractIDLocked(
|
|||
return;
|
||||
}
|
||||
|
||||
mContractIDs.Put(nsDependentCString(aEntry->contractid), f);
|
||||
mContractIDs.Put(AsLiteralCString(aEntry->contractid), f);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Загрузка…
Ссылка в новой задаче