perf(uORB): skip the queue offset division for single-slot topics

Assisted-by: Claude:claude-fable-5-1
This commit is contained in:
Lourens Naude authored and Beat Küng committed 2026-10-22 08:26:26 +02:00
1 parent d4a86b5d43
commit c283d61ef3
1 file changed
+3 -1
+3 -1
View File
@@ -194,7 +194,9 @@ uORB::DeviceNode::write(cdev::file_t *filp, const char *buffer, size_t buflen)
/* wrap-around happens after ~49 days, assuming a publisher rate of 1 kHz */
unsigned generation = _generation.fetch_add(1);
memcpy(_data + (_meta->o_size * (generation % _meta->o_queue)), buffer, _meta->o_size);
// depth-one topics always use slot 0: skip the division
const size_t offset = (_meta->o_queue > 1) ? (_meta->o_size * (generation % _meta->o_queue)) : 0;
memcpy(_data + offset, buffer, _meta->o_size);
// callbacks
for (auto item : _callbacks) {