Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: Source/wtf/TerminatedArrayBuilder.h

Issue 397733004: Allow assertions to be enabled in Blink Release builds. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/wtf/SizeLimits.cpp ('k') | Source/wtf/ThreadRestrictionVerifier.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 #ifndef TerminatedArrayBuilder_h 4 #ifndef TerminatedArrayBuilder_h
5 #define TerminatedArrayBuilder_h 5 #define TerminatedArrayBuilder_h
6 6
7 #include "wtf/OwnPtr.h" 7 #include "wtf/OwnPtr.h"
8 8
9 namespace WTF { 9 namespace WTF {
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 typename ArrayType<T>::Allocator::PassPtr release() 48 typename ArrayType<T>::Allocator::PassPtr release()
49 { 49 {
50 RELEASE_ASSERT(m_count == m_capacity); 50 RELEASE_ASSERT(m_count == m_capacity);
51 if (m_array) 51 if (m_array)
52 m_array->at(m_count - 1).setLastInArray(true); 52 m_array->at(m_count - 1).setLastInArray(true);
53 assertValid(); 53 assertValid();
54 return m_array.release(); 54 return m_array.release();
55 } 55 }
56 56
57 private: 57 private:
58 #ifndef NDEBUG 58 #if ENABLE(ASSERT)
59 void assertValid() 59 void assertValid()
60 { 60 {
61 for (size_t i = 0; i < m_count; ++i) { 61 for (size_t i = 0; i < m_count; ++i) {
62 bool isLastInArray = (i + 1 == m_count); 62 bool isLastInArray = (i + 1 == m_count);
63 ASSERT(m_array->at(i).isLastInArray() == isLastInArray); 63 ASSERT(m_array->at(i).isLastInArray() == isLastInArray);
64 } 64 }
65 } 65 }
66 #else 66 #else
67 void assertValid() { } 67 void assertValid() { }
68 #endif 68 #endif
69 69
70 typename ArrayType<T>::Allocator::Ptr m_array; 70 typename ArrayType<T>::Allocator::Ptr m_array;
71 size_t m_count; 71 size_t m_count;
72 size_t m_capacity; 72 size_t m_capacity;
73 }; 73 };
74 74
75 } // namespace WTF 75 } // namespace WTF
76 76
77 using WTF::TerminatedArrayBuilder; 77 using WTF::TerminatedArrayBuilder;
78 78
79 #endif // TerminatedArrayBuilder_h 79 #endif // TerminatedArrayBuilder_h
OLDNEW
« no previous file with comments | « Source/wtf/SizeLimits.cpp ('k') | Source/wtf/ThreadRestrictionVerifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698