MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / applyDatasetValueSpan

Method applyDatasetValueSpan

app/src/DataModel/FrameBuilder.cpp:1311–1380  ·  view source on GitHub ↗

* @brief Span twin of applyDatasetValue: in-place writes keep the producer allocation-free. The * span lane never runs during playback, so unlike its twin it needs no final-value player * check before applying the transform. */

Source from the content-addressed store, hash-verified

1309 * check before applying the transform.
1310 */
1311SS_HOT void DataModel::FrameBuilder::applyDatasetValueSpan(Dataset& dataset,
1312 const QByteArrayView* spans,
1313 qsizetype count,
1314 const TransformFrameInfo& info)
1315{
1316 Q_ASSERT(spans != nullptr);
1317 SS_ASSUME(count > 0);
1318
1319 DatasetDeps* dep = nullptr;
1320 if (m_changeDriven && dataset.virtual_ && !dataset.transformCode.isEmpty()) {
1321 dep = &m_datasetDeps[dataset.uniqueId];
1322 if (!dep->readSlots.empty() && !m_tableStore.changedSince(dep->readSlots, dep->lastRunClock))
1323 return;
1324 }
1325
1326 if (dataset.virtual_) {
1327 dataset.numericValue = 0.0;
1328 dataset.value.clear();
1329 dataset.isNumeric = true;
1330 } else {
1331 const int idx = dataset.index;
1332 if (idx <= 0 || idx > count) [[unlikely]]
1333 return;
1334
1335 // code-verify off
1336 // Restates the guard above; never assume idx range before the bounds check on a parsed frame.
1337 SS_ASSUME(idx >= 1 && idx <= count);
1338 // code-verify on
1339
1340 const QByteArrayView token = spans[idx - 1];
1341 DataModel::assign_utf8_in_place(dataset.value, token);
1342 dataset.numericValue = SerialStudio::toDouble(token, &dataset.isNumeric);
1343 }
1344
1345 dataset.rawNumericValue = dataset.numericValue;
1346 DataModel::assign_string_in_place(dataset.rawValue, dataset.value);
1347
1348 if (m_captureDatasetValues)
1349 m_tableStore.setDatasetRaw(
1350 dataset.uniqueId, dataset.numericValue, dataset.value, dataset.isNumeric);
1351
1352 if (!dataset.transformCode.isEmpty()) [[unlikely]] {
1353 const auto input = dataset.isNumeric ? QVariant(dataset.numericValue) : QVariant(dataset.value);
1354 if (dep)
1355 m_tableStore.setReadCaptureTarget(&dep->readSlots);
1356
1357 const auto result = applyTransform(dataset.transformLanguage, dataset.uniqueId, input, info);
1358
1359 if (dep) {
1360 m_tableStore.setReadCaptureTarget(nullptr);
1361 dep->lastRunClock = m_tableStore.writeClock();
1362 }
1363
1364 if (result.typeId() == QMetaType::Double) {
1365 dataset.numericValue = SerialStudio::toDouble(result);
1366 dataset.value = QString::number(dataset.numericValue, 'g', 15);
1367 dataset.isNumeric = true;
1368 } else {

Callers

nothing calls this directly

Calls 10

assign_utf8_in_placeFunction · 0.85
assign_string_in_placeFunction · 0.85
isEmptyMethod · 0.80
emptyMethod · 0.80
changedSinceMethod · 0.80
setDatasetRawMethod · 0.80
setReadCaptureTargetMethod · 0.80
writeClockMethod · 0.80
setDatasetFinalMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected