Commit 13d73dc6 authored by darin's avatar darin

* kjs/property_map.cpp:

	(PropertyMap::save): Look at the attributes the same way in the single hash entry
	case as in the actual hash table case. Change the rule for which attributes to save
	to "attributes that don't have the ReadOnly, DontEnum, or Function bit set".
        Also fix bug where saving an empty property map would leave the count set to the old value.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2882 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3f05b75a
2002-11-26 Darin Adler <darin@apple.com>
* kjs/property_map.cpp:
(PropertyMap::save): Look at the attributes the same way in the single hash entry
case as in the actual hash table case. Change the rule for which attributes to save
to "attributes that don't have the ReadOnly, DontEnum, or Function bit set".
Also fix bug where saving an empty property map would leave the count set to the old value.
2002-11-26 Richard Williamson <rjw@apple.com>
Remove debugging code. Could be cause of performance regresssion.
......
2002-11-26 Darin Adler <darin@apple.com>
* kjs/property_map.cpp:
(PropertyMap::save): Look at the attributes the same way in the single hash entry
case as in the actual hash table case. Change the rule for which attributes to save
to "attributes that don't have the ReadOnly, DontEnum, or Function bit set".
Also fix bug where saving an empty property map would leave the count set to the old value.
2002-11-26 Richard Williamson <rjw@apple.com>
Remove debugging code. Could be cause of performance regresssion.
......
2002-11-26 Darin Adler <darin@apple.com>
* kjs/property_map.cpp:
(PropertyMap::save): Look at the attributes the same way in the single hash entry
case as in the actual hash table case. Change the rule for which attributes to save
to "attributes that don't have the ReadOnly, DontEnum, or Function bit set".
Also fix bug where saving an empty property map would leave the count set to the old value.
2002-11-26 Richard Williamson <rjw@apple.com>
Remove debugging code. Could be cause of performance regresssion.
......
......@@ -24,6 +24,7 @@
#include "object.h"
#include "reference_list.h"
#define DEBUG_PROPERTIES 0
#define DO_CONSISTENCY_CHECK 0
#define DUMP_STATISTICS 0
#define USE_SINGLE_ENTRY 1
......@@ -61,7 +62,7 @@ struct PropertyMapHashTable
int keyCount;
PropertyMapHashTableEntry entries[1];
};
class SavedProperty {
public:
Identifier key;
......@@ -73,9 +74,7 @@ SavedProperties::SavedProperties() : _count(0), _properties(0) { }
SavedProperties::~SavedProperties()
{
if (_properties){
delete [] _properties;
}
delete [] _properties;
}
// Algorithm concepts from Algorithms in C++, Sedgewick.
......@@ -187,7 +186,7 @@ ValueImp *PropertyMap::get(const Identifier &name) const
return 0;
}
#ifdef DEBUG_PROPERTIES
#if DEBUG_PROPERTIES
static void printAttributes(int attributes)
{
if (attributes == 0)
......@@ -211,7 +210,7 @@ void PropertyMap::put(const Identifier &name, ValueImp *value, int attributes)
UString::Rep *rep = name._ustring.rep;
#ifdef DEBUG_PROPERTIES
#if DEBUG_PROPERTIES
printf ("adding property %s, attributes = 0x%08x (", name.ascii(), attributes);
printAttributes(attributes);
printf (")\n");
......@@ -439,39 +438,40 @@ void PropertyMap::save(SavedProperties &p) const
if (!_table) {
#if USE_SINGLE_ENTRY
if (_singleEntry.key)
if (_singleEntry.key && !(_singleEntry.attributes & (ReadOnly | DontEnum | Function)))
++count;
#endif
} else {
for (int i = 0; i != _table->size; ++i)
if (_table->entries[i].key && (_table->entries[i].attributes == 0 || _table->entries[i].attributes == (DontDelete | Internal)))
//if (_table->entries[i].key)
if (_table->entries[i].key && !(_table->entries[i].attributes & (ReadOnly | DontEnum | Function)))
++count;
}
delete [] p._properties;
p._count = count;
if (count == 0) {
p._properties = 0;
return;
}
p._properties = new SavedProperty [count];
p._count = count;
SavedProperty *prop = p._properties;
if (!_table) {
#if USE_SINGLE_ENTRY
if (_singleEntry.key) {
if (_singleEntry.key && !(_singleEntry.attributes & (ReadOnly | DontEnum | Function))) {
prop->key = Identifier(_singleEntry.key);
prop->value = Value(_singleEntry.value);
prop->attributes = _singleEntry.attributes;
++prop;
}
#endif
} else {
for (int i = 0; i != _table->size; ++i) {
if (_table->entries[i].key && (_table->entries[i].attributes == 0 || _table->entries[i].attributes == (DontDelete | Internal))) {
//if (_table->entries[i].key) {
if (_table->entries[i].key && !(_table->entries[i].attributes & (ReadOnly | DontEnum | Function))) {
prop->key = Identifier(_table->entries[i].key);
prop->value = Value(_table->entries[i].value);
prop->attributes = _table->entries[i].attributes;
......@@ -483,9 +483,8 @@ void PropertyMap::save(SavedProperties &p) const
void PropertyMap::restore(const SavedProperties &p)
{
for (int i = 0; i != p._count; ++i){
for (int i = 0; i != p._count; ++i)
put(p._properties[i].key, p._properties[i].value.imp(), p._properties[i].attributes);
}
}
#if DO_CONSISTENCY_CHECK
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment