Changeset 157049 in webkit


Ignore:
Timestamp:
Oct 7, 2013 11:07:54 AM (11 years ago)
Author:
andersca@apple.com
Message:

Remove passIn and passOut from HashTraits
https://bugs.webkit.org/show_bug.cgi?id=122452

Reviewed by Sam Weinig.

Change RefPtrHashMap to not use passOut (just like the regular HashMap) and get rid of the
passIn and passOut functions and related typedefs.

  • wtf/HashTraits.h:
  • wtf/RefPtrHashMap.h:
Location:
trunk/Source/WTF
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r157044 r157049  
     12013-10-07  Anders Carlsson  <andersca@apple.com>
     2
     3        Remove passIn and passOut from HashTraits
     4        https://bugs.webkit.org/show_bug.cgi?id=122452
     5
     6        Reviewed by Sam Weinig.
     7
     8        Change RefPtrHashMap to not use passOut (just like the regular HashMap) and get rid of the
     9        passIn and passOut functions and related typedefs.
     10
     11        * wtf/HashTraits.h:
     12        * wtf/RefPtrHashMap.h:
     13
    1142013-10-06  Anders Carlsson  <andersca@apple.com>
    215
  • trunk/Source/WTF/wtf/HashTraits.h

    r156507 r157049  
    6565    static T emptyValue() { return T(); }
    6666
    67     // Type for functions that take ownership, such as add.
    68     // The store function either not be called or called once to store something passed in.
    69     // The value passed to the store function will be either PassInType or PassInType&.
    70     typedef const T& PassInType;
    71     static void store(const T& value, T& storage) { storage = value; }
    72 
    73     // Type for return value of functions that transfer ownership, such as take.
    74     typedef T PassOutType;
    75     static PassOutType passOut(const T& value) { return value; }
    76     static T& passOut(T& value) { return value; } // Overloaded to avoid copying of non-temporary values.
    77 
    7867    // Type for return value of functions that do not transfer ownership, such as get.
    79     // FIXME: We could change this type to const T& for better performance if we figured out
    80     // a way to handle the return value from emptyValue, which is a temporary.
    8168    typedef T PeekType;
    8269    static PeekType peek(const T& value) { return value; }
     
    136123    static P* emptyValue() { return 0; }
    137124
    138     typedef PassRefPtr<P> PassInType;
    139     static void store(PassRefPtr<P> value, RefPtr<P>& storage) { storage = value; }
    140 
    141     typedef PassRefPtr<P> PassOutType;
    142     static PassRefPtr<P> passOut(RefPtr<P>& value) { return value.release(); }
    143     static PassRefPtr<P> passOut(P* value) { return value; }
    144 
    145125    typedef P* PeekType;
    146126    static PeekType peek(const RefPtr<P>& value) { return value.get(); }
  • trunk/Source/WTF/wtf/RefPtrHashMap.h

    r156492 r157049  
    4444
    4545    private:
    46         typedef typename MappedTraits::PassInType MappedPassInType;
    47         typedef typename MappedTraits::PassOutType MappedPassOutType;
    4846        typedef typename MappedTraits::PeekType MappedPeekType;
    49 
    50         typedef typename std::add_lvalue_reference<MappedPassInType>::type MappedPassInReferenceType;
    5147       
    5248        typedef HashArg HashFunctions;
     
    10298        void clear();
    10399
    104         MappedPassOutType take(const KeyType&); // efficient combination of get with remove
    105         MappedPassOutType take(RawKeyType); // efficient combination of get with remove
     100        MappedType take(const KeyType&); // efficient combination of get with remove
     101        MappedType take(RawKeyType); // efficient combination of get with remove
    106102
    107103    private:
     
    307303
    308304    template<typename T, typename U, typename V, typename W, typename MappedTraits>
    309     typename HashMap<RefPtr<T>, U, V, W, MappedTraits>::MappedPassOutType
    310     HashMap<RefPtr<T>, U, V, W, MappedTraits>::take(const KeyType& key)
     305    auto HashMap<RefPtr<T>, U, V, W, MappedTraits>::take(const KeyType& key) -> MappedType
    311306    {
    312307        iterator it = find(key);
    313308        if (it == end())
    314             return MappedTraits::passOut(MappedTraits::emptyValue());
    315         MappedPassOutType result = MappedTraits::passOut(it->value);
     309            return MappedTraits::emptyValue();
     310        MappedType value = std::move(it->value);
    316311        remove(it);
    317         return result;
    318     }
    319 
    320     template<typename T, typename U, typename V, typename W, typename MappedTraits>
    321     typename HashMap<RefPtr<T>, U, V, W, MappedTraits>::MappedPassOutType
    322     HashMap<RefPtr<T>, U, V, W, MappedTraits>::take(RawKeyType key)
     312        return value;
     313    }
     314
     315    template<typename T, typename U, typename V, typename W, typename MappedTraits>
     316    auto HashMap<RefPtr<T>, U, V, W, MappedTraits>::take(RawKeyType key) -> MappedType
    323317    {
    324318        iterator it = find(key);
    325319        if (it == end())
    326             return MappedTraits::passOut(MappedTraits::emptyValue());
    327         MappedPassOutType result = MappedTraits::passOut(it->value);
     320            return MappedTraits::emptyValue();
     321        MappedType value = std::move(it->value);
    328322        remove(it);
    329         return result;
     323        return value;
    330324    }
    331325
Note: See TracChangeset for help on using the changeset viewer.