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

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

Issue 2833123002: Replace ASSERT_NOT_REACHED, and RELEASE_ASSERT in platform/wtf (Closed)
Patch Set: wtf Created 3 years, 8 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
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 DCHECK_NE(start_, end_); 102 DCHECK_NE(start_, end_);
103 return *(--end()); 103 return *(--end());
104 } 104 }
105 const T& back() const { 105 const T& back() const {
106 DCHECK_NE(start_, end_); 106 DCHECK_NE(start_, end_);
107 return *(--end()); 107 return *(--end());
108 } 108 }
109 T TakeLast(); 109 T TakeLast();
110 110
111 T& at(size_t i) { 111 T& at(size_t i) {
112 RELEASE_ASSERT(i < size()); 112 CHECK_LT(i, size());
113 size_t right = buffer_.capacity() - start_; 113 size_t right = buffer_.capacity() - start_;
114 return i < right ? buffer_.Buffer()[start_ + i] 114 return i < right ? buffer_.Buffer()[start_ + i]
115 : buffer_.Buffer()[i - right]; 115 : buffer_.Buffer()[i - right];
116 } 116 }
117 const T& at(size_t i) const { 117 const T& at(size_t i) const {
118 RELEASE_ASSERT(i < size()); 118 CHECK_LT(i, size());
119 size_t right = buffer_.capacity() - start_; 119 size_t right = buffer_.capacity() - start_;
120 return i < right ? buffer_.Buffer()[start_ + i] 120 return i < right ? buffer_.Buffer()[start_ + i]
121 : buffer_.Buffer()[i - right]; 121 : buffer_.Buffer()[i - right];
122 } 122 }
123 123
124 T& operator[](size_t i) { return at(i); } 124 T& operator[](size_t i) { return at(i); }
125 const T& operator[](size_t i) const { return at(i); } 125 const T& operator[](size_t i) const { return at(i); }
126 126
127 template <typename U> 127 template <typename U>
128 void push_front(U&&); 128 void push_front(U&&);
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 DCHECK_NE(index_, deque_->start_); 640 DCHECK_NE(index_, deque_->start_);
641 DCHECK(deque_->buffer_.capacity()); 641 DCHECK(deque_->buffer_.capacity());
642 if (!index_) 642 if (!index_)
643 index_ = deque_->buffer_.capacity() - 1; 643 index_ = deque_->buffer_.capacity() - 1;
644 else 644 else
645 --index_; 645 --index_;
646 } 646 }
647 647
648 template <typename T, size_t inlineCapacity, typename Allocator> 648 template <typename T, size_t inlineCapacity, typename Allocator>
649 inline T* DequeIteratorBase<T, inlineCapacity, Allocator>::After() const { 649 inline T* DequeIteratorBase<T, inlineCapacity, Allocator>::After() const {
650 RELEASE_ASSERT(index_ != deque_->end_); 650 CHECK_NE(index_, deque_->end_);
651 return &deque_->buffer_.Buffer()[index_]; 651 return &deque_->buffer_.Buffer()[index_];
652 } 652 }
653 653
654 template <typename T, size_t inlineCapacity, typename Allocator> 654 template <typename T, size_t inlineCapacity, typename Allocator>
655 inline T* DequeIteratorBase<T, inlineCapacity, Allocator>::Before() const { 655 inline T* DequeIteratorBase<T, inlineCapacity, Allocator>::Before() const {
656 RELEASE_ASSERT(index_ != deque_->start_); 656 CHECK_NE(index_, deque_->start_);
657 if (!index_) 657 if (!index_)
658 return &deque_->buffer_.buffer()[deque_->buffer_.capacity() - 1]; 658 return &deque_->buffer_.buffer()[deque_->buffer_.capacity() - 1];
659 return &deque_->buffer_.buffer()[index_ - 1]; 659 return &deque_->buffer_.buffer()[index_ - 1];
660 } 660 }
661 661
662 // This is only called if the allocator is a HeapAllocator. It is used when 662 // This is only called if the allocator is a HeapAllocator. It is used when
663 // visiting during a tracing GC. 663 // visiting during a tracing GC.
664 template <typename T, size_t inlineCapacity, typename Allocator> 664 template <typename T, size_t inlineCapacity, typename Allocator>
665 template <typename VisitorDispatcher> 665 template <typename VisitorDispatcher>
666 void Deque<T, inlineCapacity, Allocator>::Trace(VisitorDispatcher visitor) { 666 void Deque<T, inlineCapacity, Allocator>::Trace(VisitorDispatcher visitor) {
(...skipping 29 matching lines...) Expand all
696 inline void swap(Deque<T, inlineCapacity, Allocator>& a, 696 inline void swap(Deque<T, inlineCapacity, Allocator>& a,
697 Deque<T, inlineCapacity, Allocator>& b) { 697 Deque<T, inlineCapacity, Allocator>& b) {
698 a.Swap(b); 698 a.Swap(b);
699 } 699 }
700 700
701 } // namespace WTF 701 } // namespace WTF
702 702
703 using WTF::Deque; 703 using WTF::Deque;
704 704
705 #endif // WTF_Deque_h 705 #endif // WTF_Deque_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/wtf/AssertionsTest.cpp ('k') | third_party/WebKit/Source/platform/wtf/HashTable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698