diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/input/TextInputStream.cxx | 2 | ||||
-rw-r--r-- | src/pcm/FallbackResampler.cxx | 6 | ||||
-rw-r--r-- | src/util/ConstBuffer.hxx | 11 | ||||
-rw-r--r-- | src/util/WritableBuffer.hxx | 11 |
4 files changed, 26 insertions, 4 deletions
diff --git a/src/input/TextInputStream.cxx b/src/input/TextInputStream.cxx index 25b9b42fe..d7cb440b3 100644 --- a/src/input/TextInputStream.cxx +++ b/src/input/TextInputStream.cxx @@ -63,7 +63,7 @@ bool TextInputStream::ReadLine(std::string &line) the current line */ dest = buffer.Write(); assert(!dest.IsEmpty()); - dest.data[0] = '\n'; + dest[0] = '\n'; buffer.Append(1); } } while (p == nullptr); diff --git a/src/pcm/FallbackResampler.cxx b/src/pcm/FallbackResampler.cxx index d005a831c..bd3f20d86 100644 --- a/src/pcm/FallbackResampler.cxx +++ b/src/pcm/FallbackResampler.cxx @@ -85,7 +85,7 @@ pcm_resample_fallback(PcmBuffer &buffer, while (dest_pos < dest_samples) { unsigned src_pos = dest_pos * src_rate / dest_rate; - dest_buffer[dest_pos++] = src.data[src_pos]; + dest_buffer[dest_pos++] = src[src_pos]; } break; case 2: @@ -93,8 +93,8 @@ pcm_resample_fallback(PcmBuffer &buffer, unsigned src_pos = dest_pos * src_rate / dest_rate; src_pos &= ~1; - dest_buffer[dest_pos++] = src.data[src_pos]; - dest_buffer[dest_pos++] = src.data[src_pos + 1]; + dest_buffer[dest_pos++] = src[src_pos]; + dest_buffer[dest_pos++] = src[src_pos + 1]; } break; } diff --git a/src/util/ConstBuffer.hxx b/src/util/ConstBuffer.hxx index 7f1fa5aa6..6754cb065 100644 --- a/src/util/ConstBuffer.hxx +++ b/src/util/ConstBuffer.hxx @@ -143,6 +143,17 @@ struct ConstBuffer { constexpr const_iterator cend() const { return data + size; } + +#ifdef NDEBUG + constexpr +#endif + const T &operator[](size_type i) const { +#ifndef NDEBUG + assert(i < size); +#endif + + return data[i]; + } }; #endif diff --git a/src/util/WritableBuffer.hxx b/src/util/WritableBuffer.hxx index 64e6d0c62..d13f80867 100644 --- a/src/util/WritableBuffer.hxx +++ b/src/util/WritableBuffer.hxx @@ -145,6 +145,17 @@ struct WritableBuffer { constexpr const_iterator cend() const { return data + size; } + +#ifdef NDEBUG + constexpr +#endif + T &operator[](size_type i) const { +#ifndef NDEBUG + assert(i < size); +#endif + + return data[i]; + } }; #endif |