Changeset 14728 in webkit for trunk/JavaScriptCore/wtf


Ignore:
Timestamp:
Jun 4, 2006, 3:51:57 PM (19 years ago)
Author:
darin
Message:

Reviewed by Anders.

  • changed deleteAllValues so it can work on "const" collections Deleting the values affects the values, not the pointers in the collection, so it's legitimate to do it to a const collection, and a case of that actually came up in the XPath code.
  • wtf/HashMap.h: (WTF::deleteAllPairSeconds): Use const iterators. (WTF::deleteAllValues): Take const HashMap reference as a parameter.
  • wtf/HashSet.h: (WTF::deleteAllValues): Take const HashSet reference as a parameter, and use const iterators.
  • wtf/Vector.h: (WTF::deleteAllValues): Take const Vector reference as a parameter.
  • added more functions that are present in <math.h> on some platforms, but not on others; moved here from various files in WebCore
  • wtf/MathExtras.h: (isinf): Added. (isnan): Added. (lround): Added. (lroundf): Tweaked. (round): Added. (roundf): Tweaked. (signbit): Added.
Location:
trunk/JavaScriptCore/wtf
Files:
4 edited

Legend:

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

    r14256 r14728  
    309309    void deleteAllPairSeconds(HashTableType& collection)
    310310    {
    311         typedef typename HashTableType::iterator iterator;
     311        typedef typename HashTableType::const_iterator iterator;
    312312        iterator end = collection.end();
    313313        for (iterator it = collection.begin(); it != end; ++it)
     
    316316
    317317    template<typename T, typename U, typename V, typename W, typename X>
    318     inline void deleteAllValues(HashMap<T, U, V, W, X>& collection)
     318    inline void deleteAllValues(const HashMap<T, U, V, W, X>& collection)
    319319    {
    320320        deleteAllPairSeconds<typename HashMap<T, U, V, W, X>::MappedType>(collection);
  • trunk/JavaScriptCore/wtf/HashSet.h

    r14256 r14728  
    3333    template<typename Value, typename HashFunctions, typename Traits> class HashSet;
    3434    template<typename Value, typename HashFunctions, typename Traits>
    35     void deleteAllValues(HashSet<Value, HashFunctions, Traits>&);
     35    void deleteAllValues(const HashSet<Value, HashFunctions, Traits>&);
    3636
    3737    template<typename ValueArg, typename HashArg = typename DefaultHash<ValueArg>::Hash,
     
    9292        void derefAll();
    9393
    94         friend void deleteAllValues<>(HashSet&);
     94        friend void deleteAllValues<>(const HashSet&);
    9595
    9696        HashTableType m_impl;
     
    295295    void deleteAllValues(HashTableType& collection)
    296296    {
    297         typedef typename HashTableType::iterator iterator;
     297        typedef typename HashTableType::const_iterator iterator;
    298298        iterator end = collection.end();
    299299        for (iterator it = collection.begin(); it != end; ++it)
     
    302302
    303303    template<typename T, typename U, typename V>
    304     inline void deleteAllValues(HashSet<T, U, V>& collection)
     304    inline void deleteAllValues(const HashSet<T, U, V>& collection)
    305305    {
    306306        deleteAllValues<typename HashSet<T, U, V>::ValueType>(collection.m_impl);
  • trunk/JavaScriptCore/wtf/MathExtras.h

    r14522 r14728  
    2828#if PLATFORM(WIN)
    2929
    30 inline float roundf(float num)
    31 {
    32     return num > 0 ? floorf(num + 0.5f) : ceilf(num - 0.5f);
    33 }
     30#include <xmath.h>
    3431
    35 inline long lroundf(float num)
    36 {
    37     return num > 0 ? num + 0.5f : ceilf(num - 0.5f);
    38 }
     32inline bool isinf(double num) { return !_finite(num); }
     33inline bool isnan(double num) { return _isnan(num); }
     34inline long lround(double num) { return num > 0 ? num + 0.5 : ceil(num - 0.5); }
     35inline long lroundf(float num) { return num > 0 ? num + 0.5f : ceilf(num - 0.5f); }
     36inline double round(double num) { return num > 0 ? floor(num + 0.5) : ceil(num - 0.5); }
     37inline float roundf(float num) { return num > 0 ? floorf(num + 0.5f) : ceilf(num - 0.5f); }
     38inline bool signbit(double num) { return _copysign(1.0, num) < 0; }
    3939
    4040#endif
  • trunk/JavaScriptCore/wtf/Vector.h

    r14263 r14728  
    580580
    581581    template<typename T, size_t inlineCapacity>
    582     void deleteAllValues(Vector<T, inlineCapacity>& collection)
    583     {
    584         typedef Vector<T, inlineCapacity> Vec;
    585         typename Vec::iterator end = collection.end();
    586         for (typename Vec::iterator it = collection.begin(); it != end; ++it)
     582    void deleteAllValues(const Vector<T, inlineCapacity>& collection)
     583    {
     584        typedef typename Vector<T, inlineCapacity>::const_iterator iterator;
     585        iterator end = collection.end();
     586        for (iterator it = collection.begin(); it != end; ++it)
    587587            delete *it;
    588588    }
Note: See TracChangeset for help on using the changeset viewer.