| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #define WTF_Vector_h | 22 #define WTF_Vector_h |
| 23 | 23 |
| 24 #include "wtf/Alignment.h" | 24 #include "wtf/Alignment.h" |
| 25 #include "wtf/FastAllocBase.h" | 25 #include "wtf/FastAllocBase.h" |
| 26 #include "wtf/Noncopyable.h" | 26 #include "wtf/Noncopyable.h" |
| 27 #include "wtf/NotFound.h" | 27 #include "wtf/NotFound.h" |
| 28 #include "wtf/QuantizedAllocation.h" | 28 #include "wtf/QuantizedAllocation.h" |
| 29 #include "wtf/StdLibExtras.h" | 29 #include "wtf/StdLibExtras.h" |
| 30 #include "wtf/UnusedParam.h" | 30 #include "wtf/UnusedParam.h" |
| 31 #include "wtf/VectorTraits.h" | 31 #include "wtf/VectorTraits.h" |
| 32 #include <string.h> |
| 32 #include <utility> | 33 #include <utility> |
| 33 #include <string.h> | |
| 34 | 34 |
| 35 namespace WTF { | 35 namespace WTF { |
| 36 | 36 |
| 37 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) | 37 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
| 38 static const size_t kInitialVectorSize = 1; | 38 static const size_t kInitialVectorSize = 1; |
| 39 #else | 39 #else |
| 40 #ifndef WTF_VECTOR_INITIAL_SIZE | 40 #ifndef WTF_VECTOR_INITIAL_SIZE |
| 41 #define WTF_VECTOR_INITIAL_SIZE 4 | 41 #define WTF_VECTOR_INITIAL_SIZE 4 |
| 42 #endif | 42 #endif |
| 43 static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE; | 43 static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE; |
| (...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 ASSERT(begin()); | 937 ASSERT(begin()); |
| 938 | 938 |
| 939 new (NotNull, end()) T(*ptr); | 939 new (NotNull, end()) T(*ptr); |
| 940 ++m_size; | 940 ++m_size; |
| 941 } | 941 } |
| 942 | 942 |
| 943 // This version of append saves a branch in the case where you know that the | 943 // This version of append saves a branch in the case where you know that the |
| 944 // vector's capacity is large enough for the append to succeed. | 944 // vector's capacity is large enough for the append to succeed. |
| 945 | 945 |
| 946 template<typename T, size_t inlineCapacity> template<typename U> | 946 template<typename T, size_t inlineCapacity> template<typename U> |
| 947 inline void Vector<T, inlineCapacity>::uncheckedAppend(const U& val) | 947 ALWAYS_INLINE void Vector<T, inlineCapacity>::uncheckedAppend(const U& val) |
| 948 { | 948 { |
| 949 ASSERT(size() < capacity()); | 949 ASSERT(size() < capacity()); |
| 950 const U* ptr = &val; | 950 const U* ptr = &val; |
| 951 new (NotNull, end()) T(*ptr); | 951 new (NotNull, end()) T(*ptr); |
| 952 ++m_size; | 952 ++m_size; |
| 953 } | 953 } |
| 954 | 954 |
| 955 // This method should not be called append, a better name would be appendEle
ments. | 955 // This method should not be called append, a better name would be appendEle
ments. |
| 956 // It could also be eliminated entirely, and call sites could just use | 956 // It could also be eliminated entirely, and call sites could just use |
| 957 // appendRange(val.begin(), val.end()). | 957 // appendRange(val.begin(), val.end()). |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 inline bool operator!=(const Vector<T, inlineCapacity>& a, const Vector<T, i
nlineCapacity>& b) | 1080 inline bool operator!=(const Vector<T, inlineCapacity>& a, const Vector<T, i
nlineCapacity>& b) |
| 1081 { | 1081 { |
| 1082 return !(a == b); | 1082 return !(a == b); |
| 1083 } | 1083 } |
| 1084 | 1084 |
| 1085 } // namespace WTF | 1085 } // namespace WTF |
| 1086 | 1086 |
| 1087 using WTF::Vector; | 1087 using WTF::Vector; |
| 1088 | 1088 |
| 1089 #endif // WTF_Vector_h | 1089 #endif // WTF_Vector_h |
| OLD | NEW |