Ignore:
Timestamp:
Nov 20, 2002, 5:28:08 PM (23 years ago)
Author:
darin
Message:
  • added a feature for Richard to use in his back/forward cache
  • kjs/object.h: Added save/restoreProperties.
  • kjs/property_map.h: Here too.
  • kjs/property_map.cpp: Here too.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/property_map.cpp

    r2783 r2794  
    2626#include "reference_list.h"
    2727
    28 // At the time I added this, the optimization still gave a 1.5% performance boost.
     28// At the time I added this switch, the optimization still gave a 1.5% performance boost so I couldn't remove it.
    2929#define USE_SINGLE_ENTRY 1
    3030
    3131namespace KJS {
     32
     33class SavedProperty {
     34public:
     35    Identifier key;
     36    Value value;
     37};
    3238
    3339// Algorithm concepts from Algorithms in C++, Sedgewick.
     
    282288}
    283289
     290void PropertyMap::save(SavedProperties &p) const
     291{
     292    int count = 0;
     293
     294#if USE_SINGLE_ENTRY
     295    if (_singleEntry.key)
     296        ++count;
     297#endif
     298    for (int i = 0; i != _tableSize; ++i)
     299        if (_table[i].key && _table[i].attributes == 0)
     300            ++count;
     301
     302    delete [] p._properties;
     303    if (count == 0) {
     304        p._properties = 0;
     305        return;
     306    }
     307    p._properties = new SavedProperty [count];
     308   
     309    SavedProperty *prop = p._properties;
     310   
     311#if USE_SINGLE_ENTRY
     312    if (_singleEntry.key) {
     313        prop->key = Identifier(_singleEntry.key);
     314        prop->value = Value(_singleEntry.value);
     315        ++prop;
     316    }
     317#endif
     318    for (int i = 0; i != _tableSize; ++i)
     319        if (_table[i].key && _table[i].attributes == 0) {
     320            prop->key = Identifier(_table[i].key);
     321            prop->value = Value(_table[i].value);
     322        }
     323}
     324
     325void PropertyMap::restore(const SavedProperties &p)
     326{
     327    for (int i = 0; i != p._count; ++i)
     328        put(p._properties[i].key, p._properties[i].value.imp(), 0);
     329}
     330
    284331} // namespace KJS
Note: See TracChangeset for help on using the changeset viewer.