-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is the memset in clear() necessary? #9
Comments
I've taken your advice and actually turned the |
if head and tail positions are reset, or a read/pop is done, theres no point to discard data in that slot as its not included in the queue, and further writes will override it anyways adding memset is pretty redundant, but not necessary |
if we all agree there is no value in having that clear up, I will remove it in the next version... |
Awesome, thanks for looking into it so quick :) |
I've removed the |
Hello!
I've been working on a project using this library and noticed that the clear() function seemed to be taking an inordinately long time on my microcontroller. I did a little digging, and the culprit seems to be this line below, where you use memset() to erase all the data in the buffer:
CircularBuffer/CircularBuffer.tpp
Line 134 in 473845e
Since that function sets the head, tail, and count variables, my suspicion was that this memset isn't actually required. The constructors seem to confirm this since they don't memset the buffer on creation (unless it gets initialized to 0 some other way I'm not seeing).
I went ahead and tested this out and everything seems to work great on my project at least, so I wanted to drop you a message and let you know in case this is a nice low-hanging fruit speedup. If I'm wrong and that is important, then that'd be good to know too so I don't end up hitting some sneaky bug later on.
Love the library, btw! Thanks for writing it, it's saved me a lot of time
Thanks, Charlie
The text was updated successfully, but these errors were encountered: