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

Side by Side Diff: third_party/WebKit/Source/wtf/Deque.h

Issue 2585673002: Replace ASSERT, ENABLE(ASSERT), and ASSERT_NOT_REACHED in wtf (Closed)
Patch Set: Fix an Asan issue with LinkedHashSetNodeBase::unlink Created 4 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 reverse_iterator rbegin() { return reverse_iterator(end()); } 83 reverse_iterator rbegin() { return reverse_iterator(end()); }
84 reverse_iterator rend() { return reverse_iterator(begin()); } 84 reverse_iterator rend() { return reverse_iterator(begin()); }
85 const_reverse_iterator rbegin() const { 85 const_reverse_iterator rbegin() const {
86 return const_reverse_iterator(end()); 86 return const_reverse_iterator(end());
87 } 87 }
88 const_reverse_iterator rend() const { 88 const_reverse_iterator rend() const {
89 return const_reverse_iterator(begin()); 89 return const_reverse_iterator(begin());
90 } 90 }
91 91
92 T& first() { 92 T& first() {
93 ASSERT(m_start != m_end); 93 DCHECK_NE(m_start, m_end);
94 return m_buffer.buffer()[m_start]; 94 return m_buffer.buffer()[m_start];
95 } 95 }
96 const T& first() const { 96 const T& first() const {
97 ASSERT(m_start != m_end); 97 DCHECK_NE(m_start, m_end);
98 return m_buffer.buffer()[m_start]; 98 return m_buffer.buffer()[m_start];
99 } 99 }
100 T takeFirst(); 100 T takeFirst();
101 101
102 T& last() { 102 T& last() {
103 ASSERT(m_start != m_end); 103 DCHECK_NE(m_start, m_end);
104 return *(--end()); 104 return *(--end());
105 } 105 }
106 const T& last() const { 106 const T& last() const {
107 ASSERT(m_start != m_end); 107 DCHECK_NE(m_start, m_end);
108 return *(--end()); 108 return *(--end());
109 } 109 }
110 T takeLast(); 110 T takeLast();
111 111
112 T& at(size_t i) { 112 T& at(size_t i) {
113 RELEASE_ASSERT(i < size()); 113 RELEASE_ASSERT(i < size());
114 size_t right = m_buffer.capacity() - m_start; 114 size_t right = m_buffer.capacity() - m_start;
115 return i < right ? m_buffer.buffer()[m_start + i] 115 return i < right ? m_buffer.buffer()[m_start + i]
116 : m_buffer.buffer()[i - right]; 116 : m_buffer.buffer()[i - right];
117 } 117 }
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 expandCapacityIfNeeded(); 498 expandCapacityIfNeeded();
499 if (!m_start) 499 if (!m_start)
500 m_start = m_buffer.capacity() - 1; 500 m_start = m_buffer.capacity() - 1;
501 else 501 else
502 --m_start; 502 --m_start;
503 new (NotNull, &m_buffer.buffer()[m_start]) T(std::forward<U>(value)); 503 new (NotNull, &m_buffer.buffer()[m_start]) T(std::forward<U>(value));
504 } 504 }
505 505
506 template <typename T, size_t inlineCapacity, typename Allocator> 506 template <typename T, size_t inlineCapacity, typename Allocator>
507 inline void Deque<T, inlineCapacity, Allocator>::removeFirst() { 507 inline void Deque<T, inlineCapacity, Allocator>::removeFirst() {
508 ASSERT(!isEmpty()); 508 DCHECK(!isEmpty());
509 TypeOperations::destruct(&m_buffer.buffer()[m_start], 509 TypeOperations::destruct(&m_buffer.buffer()[m_start],
510 &m_buffer.buffer()[m_start + 1]); 510 &m_buffer.buffer()[m_start + 1]);
511 m_buffer.clearUnusedSlots(&m_buffer.buffer()[m_start], 511 m_buffer.clearUnusedSlots(&m_buffer.buffer()[m_start],
512 &m_buffer.buffer()[m_start + 1]); 512 &m_buffer.buffer()[m_start + 1]);
513 if (m_start == m_buffer.capacity() - 1) 513 if (m_start == m_buffer.capacity() - 1)
514 m_start = 0; 514 m_start = 0;
515 else 515 else
516 ++m_start; 516 ++m_start;
517 } 517 }
518 518
519 template <typename T, size_t inlineCapacity, typename Allocator> 519 template <typename T, size_t inlineCapacity, typename Allocator>
520 inline void Deque<T, inlineCapacity, Allocator>::removeLast() { 520 inline void Deque<T, inlineCapacity, Allocator>::removeLast() {
521 ASSERT(!isEmpty()); 521 DCHECK(!isEmpty());
522 if (!m_end) 522 if (!m_end)
523 m_end = m_buffer.capacity() - 1; 523 m_end = m_buffer.capacity() - 1;
524 else 524 else
525 --m_end; 525 --m_end;
526 TypeOperations::destruct(&m_buffer.buffer()[m_end], 526 TypeOperations::destruct(&m_buffer.buffer()[m_end],
527 &m_buffer.buffer()[m_end + 1]); 527 &m_buffer.buffer()[m_end + 1]);
528 m_buffer.clearUnusedSlots(&m_buffer.buffer()[m_end], 528 m_buffer.clearUnusedSlots(&m_buffer.buffer()[m_end],
529 &m_buffer.buffer()[m_end + 1]); 529 &m_buffer.buffer()[m_end + 1]);
530 } 530 }
531 531
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 inline DequeIteratorBase<T, inlineCapacity, Allocator>::~DequeIteratorBase() {} 591 inline DequeIteratorBase<T, inlineCapacity, Allocator>::~DequeIteratorBase() {}
592 592
593 template <typename T, size_t inlineCapacity, typename Allocator> 593 template <typename T, size_t inlineCapacity, typename Allocator>
594 inline bool DequeIteratorBase<T, inlineCapacity, Allocator>::isEqual( 594 inline bool DequeIteratorBase<T, inlineCapacity, Allocator>::isEqual(
595 const DequeIteratorBase& other) const { 595 const DequeIteratorBase& other) const {
596 return m_index == other.m_index; 596 return m_index == other.m_index;
597 } 597 }
598 598
599 template <typename T, size_t inlineCapacity, typename Allocator> 599 template <typename T, size_t inlineCapacity, typename Allocator>
600 inline void DequeIteratorBase<T, inlineCapacity, Allocator>::increment() { 600 inline void DequeIteratorBase<T, inlineCapacity, Allocator>::increment() {
601 ASSERT(m_index != m_deque->m_end); 601 DCHECK_NE(m_index, m_deque->m_end);
602 ASSERT(m_deque->m_buffer.capacity()); 602 DCHECK(m_deque->m_buffer.capacity());
603 if (m_index == m_deque->m_buffer.capacity() - 1) 603 if (m_index == m_deque->m_buffer.capacity() - 1)
604 m_index = 0; 604 m_index = 0;
605 else 605 else
606 ++m_index; 606 ++m_index;
607 } 607 }
608 608
609 template <typename T, size_t inlineCapacity, typename Allocator> 609 template <typename T, size_t inlineCapacity, typename Allocator>
610 inline void DequeIteratorBase<T, inlineCapacity, Allocator>::decrement() { 610 inline void DequeIteratorBase<T, inlineCapacity, Allocator>::decrement() {
611 ASSERT(m_index != m_deque->m_start); 611 DCHECK_NE(m_index, m_deque->m_start);
612 ASSERT(m_deque->m_buffer.capacity()); 612 DCHECK(m_deque->m_buffer.capacity());
613 if (!m_index) 613 if (!m_index)
614 m_index = m_deque->m_buffer.capacity() - 1; 614 m_index = m_deque->m_buffer.capacity() - 1;
615 else 615 else
616 --m_index; 616 --m_index;
617 } 617 }
618 618
619 template <typename T, size_t inlineCapacity, typename Allocator> 619 template <typename T, size_t inlineCapacity, typename Allocator>
620 inline T* DequeIteratorBase<T, inlineCapacity, Allocator>::after() const { 620 inline T* DequeIteratorBase<T, inlineCapacity, Allocator>::after() const {
621 RELEASE_ASSERT(m_index != m_deque->m_end); 621 RELEASE_ASSERT(m_index != m_deque->m_end);
622 return &m_deque->m_buffer.buffer()[m_index]; 622 return &m_deque->m_buffer.buffer()[m_index];
623 } 623 }
624 624
625 template <typename T, size_t inlineCapacity, typename Allocator> 625 template <typename T, size_t inlineCapacity, typename Allocator>
626 inline T* DequeIteratorBase<T, inlineCapacity, Allocator>::before() const { 626 inline T* DequeIteratorBase<T, inlineCapacity, Allocator>::before() const {
627 RELEASE_ASSERT(m_index != m_deque->m_start); 627 RELEASE_ASSERT(m_index != m_deque->m_start);
628 if (!m_index) 628 if (!m_index)
629 return &m_deque->m_buffer.buffer()[m_deque->m_buffer.capacity() - 1]; 629 return &m_deque->m_buffer.buffer()[m_deque->m_buffer.capacity() - 1];
630 return &m_deque->m_buffer.buffer()[m_index - 1]; 630 return &m_deque->m_buffer.buffer()[m_index - 1];
631 } 631 }
632 632
633 // This is only called if the allocator is a HeapAllocator. It is used when 633 // This is only called if the allocator is a HeapAllocator. It is used when
634 // visiting during a tracing GC. 634 // visiting during a tracing GC.
635 template <typename T, size_t inlineCapacity, typename Allocator> 635 template <typename T, size_t inlineCapacity, typename Allocator>
636 template <typename VisitorDispatcher> 636 template <typename VisitorDispatcher>
637 void Deque<T, inlineCapacity, Allocator>::trace(VisitorDispatcher visitor) { 637 void Deque<T, inlineCapacity, Allocator>::trace(VisitorDispatcher visitor) {
638 ASSERT(Allocator::isGarbageCollected); // Garbage collector must be enabled. 638 DCHECK(Allocator::isGarbageCollected) << "Garbage collector must be enabled.";
639 const T* bufferBegin = m_buffer.buffer(); 639 const T* bufferBegin = m_buffer.buffer();
640 const T* end = bufferBegin + m_end; 640 const T* end = bufferBegin + m_end;
641 if (IsTraceableInCollectionTrait<VectorTraits<T>>::value) { 641 if (IsTraceableInCollectionTrait<VectorTraits<T>>::value) {
642 if (m_start <= m_end) { 642 if (m_start <= m_end) {
643 for (const T* bufferEntry = bufferBegin + m_start; bufferEntry != end; 643 for (const T* bufferEntry = bufferBegin + m_start; bufferEntry != end;
644 bufferEntry++) 644 bufferEntry++)
645 Allocator::template trace<VisitorDispatcher, T, VectorTraits<T>>( 645 Allocator::template trace<VisitorDispatcher, T, VectorTraits<T>>(
646 visitor, *const_cast<T*>(bufferEntry)); 646 visitor, *const_cast<T*>(bufferEntry));
647 } else { 647 } else {
648 for (const T* bufferEntry = bufferBegin; bufferEntry != end; 648 for (const T* bufferEntry = bufferBegin; bufferEntry != end;
(...skipping 17 matching lines...) Expand all
666 inline void swap(Deque<T, inlineCapacity, Allocator>& a, 666 inline void swap(Deque<T, inlineCapacity, Allocator>& a,
667 Deque<T, inlineCapacity, Allocator>& b) { 667 Deque<T, inlineCapacity, Allocator>& b) {
668 a.swap(b); 668 a.swap(b);
669 } 669 }
670 670
671 } // namespace WTF 671 } // namespace WTF
672 672
673 using WTF::Deque; 673 using WTF::Deque;
674 674
675 #endif // WTF_Deque_h 675 #endif // WTF_Deque_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/DateMath.cpp ('k') | third_party/WebKit/Source/wtf/DoublyLinkedList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698