* @brief Hot-path read by handle; a stale, out-of-range, or -1 handle is a safe nullptr. */
| 384 | * @brief Hot-path read by handle; a stale, out-of-range, or -1 handle is a safe nullptr. |
| 385 | */ |
| 386 | const DataModel::RegisterValue* DataModel::DataTableStore::getByHandle(qint64 handle) const |
| 387 | { |
| 388 | Q_ASSERT(m_initialized); |
| 389 | |
| 390 | if (handle < 0) [[unlikely]] |
| 391 | return nullptr; |
| 392 | |
| 393 | const int gen = static_cast<int>(handle >> kHandleIndexBits); |
| 394 | const int index = static_cast<int>(handle & kHandleIndexMask); |
| 395 | if (gen != m_generation || index >= static_cast<int>(m_storage.size())) [[unlikely]] |
| 396 | return nullptr; |
| 397 | |
| 398 | captureRead(index); |
| 399 | return &m_storage[static_cast<size_t>(index)]; |
| 400 | } |
| 401 | |
| 402 | /** |
| 403 | * @brief Hot-path write by handle; non-computed (guard matches set()), stale, or invalid handles |
no test coverage detected