Chromium Code Reviews| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 static void clear(T*, T*) { } | 83 static void clear(T*, T*) { } |
| 84 #if ENABLE(ASSERT) | 84 #if ENABLE(ASSERT) |
| 85 static void checkCleared(const T*, const T*) { } | 85 static void checkCleared(const T*, const T*) { } |
| 86 #endif | 86 #endif |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 template<typename T> | 89 template<typename T> |
| 90 struct VectorUnusedSlotClearer<true, T> { | 90 struct VectorUnusedSlotClearer<true, T> { |
| 91 static void clear(T* begin, T* end) | 91 static void clear(T* begin, T* end) |
| 92 { | 92 { |
| 93 memset(begin, 0, sizeof(T) * (end - begin)); | 93 char* array = reinterpret_cast<char*>(begin); |
| 94 for (size_t i = 0; i < sizeof(T) * (end - begin); i++) | |
| 95 array[i] = 0; | |
|
haraken
2015/04/27 06:57:57
We cannot now use memset here because clang compla
sof
2015/04/30 21:15:47
It might rewrite that loop to a memset() applicati
haraken
2015/04/30 23:40:20
Thanks, it works.
| |
| 94 } | 96 } |
| 95 | 97 |
| 96 #if ENABLE(ASSERT) | 98 #if ENABLE(ASSERT) |
| 97 static void checkCleared(const T* begin, const T* end) | 99 static void checkCleared(const T* begin, const T* end) |
| 98 { | 100 { |
| 99 const unsigned char* unusedArea = reinterpret_cast<const unsigned ch ar*>(begin); | 101 const unsigned char* unusedArea = reinterpret_cast<const unsigned ch ar*>(begin); |
| 100 const unsigned char* endAddress = reinterpret_cast<const unsigned ch ar*>(end); | 102 const unsigned char* endAddress = reinterpret_cast<const unsigned ch ar*>(end); |
| 101 ASSERT(endAddress >= unusedArea); | 103 ASSERT(endAddress >= unusedArea); |
| 102 for (int i = 0; i < endAddress - unusedArea; ++i) | 104 for (int i = 0; i < endAddress - unusedArea; ++i) |
| 103 ASSERT(!unusedArea[i]); | 105 ASSERT(!unusedArea[i]); |
| (...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1323 struct NeedsTracing<Vector<T, N>> { | 1325 struct NeedsTracing<Vector<T, N>> { |
| 1324 static const bool value = false; | 1326 static const bool value = false; |
| 1325 }; | 1327 }; |
| 1326 #endif | 1328 #endif |
| 1327 | 1329 |
| 1328 } // namespace WTF | 1330 } // namespace WTF |
| 1329 | 1331 |
| 1330 using WTF::Vector; | 1332 using WTF::Vector; |
| 1331 | 1333 |
| 1332 #endif // WTF_Vector_h | 1334 #endif // WTF_Vector_h |
| OLD | NEW |