[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8470 - usrp2/branches/developers/jcorgan/u2/host/lib
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r8470 - usrp2/branches/developers/jcorgan/u2/host/lib |
Date: |
Wed, 21 May 2008 10:59:29 -0600 (MDT) |
Author: jcorgan
Date: 2008-05-21 10:59:27 -0600 (Wed, 21 May 2008)
New Revision: 8470
Modified:
usrp2/branches/developers/jcorgan/u2/host/lib/ring_buffer.h
Log:
Avoid exposing intermediate state, optimize
Modified: usrp2/branches/developers/jcorgan/u2/host/lib/ring_buffer.h
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/lib/ring_buffer.h 2008-05-21
01:36:28 UTC (rev 8469)
+++ usrp2/branches/developers/jcorgan/u2/host/lib/ring_buffer.h 2008-05-21
16:59:27 UTC (rev 8470)
@@ -58,7 +58,7 @@
template<class T>
size_t ring_buffer<T>::items_available() const
{
- return (d_size+d_write_index-d_read_index) & (d_size-1);
+ return (d_write_index-d_read_index) & (d_size-1);
}
template<class T>
@@ -71,8 +71,8 @@
void ring_buffer<T>::read(size_t nitems, T *items)
{
for (size_t i=0; i < nitems; i++) {
- items[i] = d_items[d_read_index++];
- d_read_index &= (d_size-1);
+ items[i] = d_items[d_read_index];
+ d_read_index = (d_read_index + 1) & (d_size-1);
}
}
@@ -80,8 +80,8 @@
void ring_buffer<T>::write(size_t nitems, const T *items)
{
for (size_t i=0; i < nitems; i++) {
- d_items[d_write_index++] = items[i];
- d_write_index &= (d_size-1);
+ d_items[d_write_index] = items[i];
+ d_write_index = (d_write_index+1) & (d_size-1);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8470 - usrp2/branches/developers/jcorgan/u2/host/lib,
jcorgan <=