Ignore:
Timestamp:
Dec 13, 2005, 3:06:10 AM (19 years ago)
Author:
mjs
Message:

JavaScriptCore:

Reviewed by Eric.

  • added a new HashCountedSet class for the common pattern of mapping items to counts that can change
  • kxmlcore/HashCountedSet.h: Added. (KXMLCore::HashCountedSet::*): Implemented, on top of HashMap.
  • kxmlcore/HashMap.h: (KXMLCore::HashMap::add): New method - does not replace existing value if key already present but otherwise like set(). (KXMLCore::HashMap::set): Improved comments.
  • kxmlcore/HashMapPtrSpec.h: (KXMLCore::HashMap::add): Added to specializations too.
  • JavaScriptCore.xcodeproj/project.pbxproj: Add new file.
  • kxmlcore/HashFunctions.h: Added include of stdint.h
  • replaced the custom hashtable for values protected from GC with HashCountedSet
  • kjs/collector.cpp: (KJS::Collector::protect): Moved code here from ProtectedValues::increaseProtectCount since the code is so simple now. (KJS::Collector::unprotect): Ditto for ProtectedValues::decreaseProtectCount. (KJS::Collector::markProtectedObjects): Updated for new way of doing things, now simpler and safer. (KJS::Collector::numReferencedObjects): ditto (KJS::Collector::rootObjectClasses): ditto
  • kjs/collector.h: Added protect and unprotect static methods
  • kjs/protect.h: (KJS::gcProtect): Updated for removal of ProtectedValues class (KJS::gcUnprotect): likewise
  • kjs/protected_values.cpp: Removed.
  • kjs/protected_values.h: Removed.

WebCore:

Reviewed by Eric.

  • updated for new HashCountedSet class
  • ForwardingHeaders/kxmlcore/HashCountedSet.h: Added forwarding header.
  • khtml/ecma/kjs_binding.cpp: Moved #define to disable pointer specialization higher in the file.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kxmlcore/HashMap.h

    r10653 r11561  
    5555    bool isEmpty() const;
    5656
     57    // iterators iterate over pairs of keys and values
    5758    iterator begin();
    5859    iterator end();
     
    6667
    6768    // replaces value but not key if key is already present
     69    // return value is a pair of the iterator to the key location,
     70    // and a boolean that's true if a new value was actually added
    6871    std::pair<iterator, bool> set(const KeyType &key, const MappedType &mapped);
     72
     73    // does nothing if key is already present
     74    // return value is a pair of the iterator to the key location,
     75    // and a boolean that's true if a new value was actually added
     76    std::pair<iterator, bool> add(const KeyType &key, const MappedType &mapped);
    6977
    7078    void remove(const KeyType& key);
     
    140148{
    141149    pair<iterator, bool> result = m_impl.insert(ValueType(key, mapped));
    142     // the insert call aboveinsert won't change anything if the key is
     150    // the insert call above won't change anything if the key is
    143151    // already there; in that case, make sure to set the value.
    144152    if (!result.second)
     
    148156
    149157template<typename Key, typename Mapped, typename HashFunctions, typename KeyTraits, typename MappedTraits>
     158std::pair<typename HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::iterator, bool> HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::add(const KeyType &key, const MappedType &mapped)
     159{
     160    return m_impl.insert(ValueType(key, mapped));
     161}
     162
     163template<typename Key, typename Mapped, typename HashFunctions, typename KeyTraits, typename MappedTraits>
    150164inline Mapped HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::get(const KeyType &key) const
    151165{
Note: See TracChangeset for help on using the changeset viewer.