mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-22 14:19:57 +08:00
perf(uORB): skip the queue offset division for single-slot topics
Assisted-by: Claude:claude-fable-5-1
This commit is contained in:
1 parent
d4a86b5d43
commit
c283d61ef3
1 file changed
+3
-1
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user