Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 } | 120 } |
| 121 | 121 |
| 122 private: | 122 private: |
| 123 static const size_t kDefaultInitialSize = 10; | 123 static const size_t kDefaultInitialSize = 10; |
| 124 | 124 |
| 125 // This method is used by the [] operators to calculate an index within the | 125 // This method is used by the [] operators to calculate an index within the |
| 126 // capacity of the array, but without using the modulo operation (%). | 126 // capacity of the array, but without using the modulo operation (%). |
| 127 static inline size_t WrapIndex(size_t index, | 127 static inline size_t WrapIndex(size_t index, |
| 128 size_t begin_index, | 128 size_t begin_index, |
| 129 size_t capacity) { | 129 size_t capacity) { |
| 130 RTC_DCHECK_GE(begin_index + index, index); // Check for overflow. | 130 RTC_DCHECK_LT(index, capacity); |
| 131 const size_t ix = | 131 RTC_DCHECK_LT(begin_index, capacity); |
| 132 begin_index + index - (begin_index + index >= capacity ? capacity : 0); | 132 size_t ix = begin_index + index; |
| 133 RTC_DCHECK_GE(ix, index); // Check for overflow. | |
|
nisse-webrtc
2017/02/22 07:48:40
Given above DCHECKS, this could fail only if capac
kwiberg-webrtc
2017/02/22 08:25:48
Aha. The two DCHECKs on line 130 and 131 guarantee
| |
| 134 if (ix >= capacity) { | |
| 135 ix -= capacity; | |
| 136 } | |
| 133 RTC_DCHECK_LT(ix, capacity); | 137 RTC_DCHECK_LT(ix, capacity); |
| 134 return ix; | 138 return ix; |
| 135 } | 139 } |
| 136 | 140 |
| 137 void Reserve(size_t n); | 141 void Reserve(size_t n); |
| 138 | 142 |
| 139 void InsertByPushBack(const int16_t* insert_this, size_t length, | 143 void InsertByPushBack(const int16_t* insert_this, size_t length, |
| 140 size_t position); | 144 size_t position); |
| 141 | 145 |
| 142 void InsertByPushFront(const int16_t* insert_this, size_t length, | 146 void InsertByPushFront(const int16_t* insert_this, size_t length, |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 155 size_t begin_index_; | 159 size_t begin_index_; |
| 156 | 160 |
| 157 // The index of the sample after the last sample in |array_|. | 161 // The index of the sample after the last sample in |array_|. |
| 158 size_t end_index_; | 162 size_t end_index_; |
| 159 | 163 |
| 160 RTC_DISALLOW_COPY_AND_ASSIGN(AudioVector); | 164 RTC_DISALLOW_COPY_AND_ASSIGN(AudioVector); |
| 161 }; | 165 }; |
| 162 | 166 |
| 163 } // namespace webrtc | 167 } // namespace webrtc |
| 164 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_AUDIO_VECTOR_H_ | 168 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_AUDIO_VECTOR_H_ |
| OLD | NEW |