Index: webrtc/modules/audio_coding/neteq/audio_vector.h |
diff --git a/webrtc/modules/audio_coding/neteq/audio_vector.h b/webrtc/modules/audio_coding/neteq/audio_vector.h |
index 756292aa783aabd0449bfd76d61a20ade77dca85..e52c5a14d1ff746b0c6c4f9b540a17e835c5052c 100644 |
--- a/webrtc/modules/audio_coding/neteq/audio_vector.h |
+++ b/webrtc/modules/audio_coding/neteq/audio_vector.h |
@@ -14,6 +14,7 @@ |
#include <string.h> // Access to size_t. |
#include <memory> |
+#include "webrtc/base/checks.h" |
#include "webrtc/base/constructormagic.h" |
#include "webrtc/typedefs.h" |
@@ -110,8 +111,21 @@ class AudioVector { |
virtual bool Empty() const; |
// Accesses and modifies an element of AudioVector. |
- const int16_t& operator[](size_t index) const; |
- int16_t& operator[](size_t index); |
+ inline const int16_t& operator[](size_t index) const { |
kwiberg-webrtc
2017/02/13 14:44:08
You should also DCHECK that begin_index_ + index d
hlundin-webrtc
2017/02/14 08:49:28
Done.
|
+ const size_t ix = begin_index_ + index >= capacity_ ? |
+ begin_index_ + index - capacity_ : |
+ begin_index_ + index; |
+ RTC_DCHECK_LT(ix, capacity_); |
+ return array_[ix]; |
+ } |
+ |
+ inline int16_t& operator[](size_t index) { |
+ const size_t ix = begin_index_ + index >= capacity_ ? |
+ begin_index_ + index - capacity_ : |
+ begin_index_ + index; |
+ RTC_DCHECK_LT(ix, capacity_); |
kwiberg-webrtc
2017/02/13 14:44:08
Break out the index calculation to a separate func
hlundin-webrtc
2017/02/14 08:49:28
Done.
|
+ return array_[ix]; |
+ } |
private: |
static const size_t kDefaultInitialSize = 10; |