[riot-notifications] [RIOT-OS/RIOT] tsrb: change input type to `uint8_t` (#11634)

Sebastian Meiling notifications at github.com
Wed Jun 5 13:33:40 CEST 2019


smlng commented on this pull request.



>  {
     rb->buf[rb->writes++ & (rb->size - 1)] = c;
 }
 
-static char _pop(tsrb_t *rb)
+static uint8_t _pop(tsrb_t *rb)
 {
     return rb->buf[rb->reads++ & (rb->size - 1)];
 }
 
 int tsrb_get_one(tsrb_t *rb)

why is it less efficient? Its simpler and (more over) type safe:

```
uint8_t tsrb_get_one(tsrb_t *rb)
{
    return _pop(rb);
}
```

and upon usage (like in isrpipe or so)

```
uint8_t c;
if (!tsrb_empty(rb)) {
    c = tsrb_get_one(rb);
}
else {
    DEBUG("ring buffer empty!\n");
    /* do error handling if required */
}
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11634#discussion_r290694135
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190605/a2c1f54e/attachment.html>


More information about the notifications mailing list