Bug 45353. Remove the pool used to keep XUL attributes now that we've improved sharing. r=shaver

This commit is contained in:
waterson%netscape.com 2001-11-29 23:49:10 +00:00
Родитель ddd6c17e3a
Коммит 6fa17abc02
2 изменённых файлов: 2 добавлений и 89 удалений

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

@ -67,6 +67,7 @@
#include "nsLayoutCID.h"
#include "nsReadableUtils.h"
#include "nsContentUtils.h"
#include "nsXULAtoms.h"
static NS_DEFINE_CID(kCSSParserCID, NS_CSSPARSER_CID);
@ -150,71 +151,6 @@ nsClassList::ParseClasses(nsClassList** aList, const nsAReadableString& aClassSt
// nsXULAttribute
//
PRInt32 nsXULAttribute::gRefCnt;
nsIAtom* nsXULAttribute::kIdAtom;
const PRInt32 nsXULAttribute::kBlockSize = 512;
nsXULAttribute* nsXULAttribute::gFreeList;
void*
nsXULAttribute::operator new(size_t aSize)
{
// Simple fixed size allocator for nsXULAttribute objects. Look
// for an object on the |gFreeList|, if there isn't one, create a
// new block of 'em.
if (aSize != sizeof(nsXULAttribute))
return ::operator new(aSize);
nsXULAttribute* result = gFreeList;
if (result) {
gFreeList = gFreeList->mNext;
}
else {
// Create a chunk o' memory for the freelist.
nsXULAttribute* block =
NS_STATIC_CAST(nsXULAttribute*, ::operator new(kBlockSize * sizeof(nsXULAttribute)));
if (! block)
return nsnull;
// Thread it.
for (PRInt32 i = 1; i < kBlockSize - 1; ++i)
block[i].mNext = &block[i + 1];
block[kBlockSize - 1].mNext = nsnull;
result = block;
gFreeList = &block[1];
}
return result;
}
void
nsXULAttribute::operator delete(void* aObject, size_t aSize)
{
// Return |aObject| to |gFreeList|, if we can.
if (! aObject)
return;
if (aSize != sizeof(nsXULAttribute)) {
::operator delete(aObject);
return;
}
#ifdef DEBUG
nsCRT::memset(aObject, 0xdd, aSize);
#endif
nsXULAttribute* doomed = NS_STATIC_CAST(nsXULAttribute*, aObject);
doomed->mNext = gFreeList;
gFreeList = doomed;
}
nsXULAttribute::nsXULAttribute(nsIContent* aContent,
nsINodeInfo* aNodeInfo,
const nsAReadableString& aValue)
@ -222,11 +158,6 @@ nsXULAttribute::nsXULAttribute(nsIContent* aContent,
mNodeInfo(aNodeInfo)
{
NS_INIT_REFCNT();
if (gRefCnt++ == 0) {
kIdAtom = NS_NewAtom("id");
}
NS_IF_ADDREF(aNodeInfo);
SetValueInternal(aValue);
}
@ -235,10 +166,6 @@ nsXULAttribute::~nsXULAttribute()
{
NS_IF_RELEASE(mNodeInfo);
mValue.ReleaseValue();
if (--gRefCnt == 0) {
NS_IF_RELEASE(kIdAtom);
}
}
nsresult
@ -539,7 +466,7 @@ nsXULAttribute::GetQualifiedName(nsAWritableString& aQualifiedName)
nsresult
nsXULAttribute::SetValueInternal(const nsAReadableString& aValue)
{
return mValue.SetValue( aValue, mNodeInfo->Equals(kIdAtom) );
return mValue.SetValue( aValue, mNodeInfo->Equals(nsXULAtoms::id) );
}
nsresult

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

@ -114,20 +114,6 @@ class nsXULAttribute : public nsIDOMAttr,
public nsIDOM3Node
{
protected:
static PRInt32 gRefCnt;
static nsIAtom* kIdAtom;
// A global fixed-size allocator for nsXULAttribute
// objects. |kBlockSize| is the number of nsXULAttribute objects
// the live together in a contiguous block of memory.
static const PRInt32 kBlockSize;
// The head of the free list for free nsXULAttribute objects.
static nsXULAttribute* gFreeList;
static void* operator new(size_t aSize);
static void operator delete(void* aObject, size_t aSize);
nsXULAttribute(nsIContent* aContent,
nsINodeInfo* aNodeInfo,
const nsAReadableString& aValue);