* @brief Span fast-path dispatch mirroring parseMultiFrameUtf8's source-0 fallback semantics. * Returns -1 when the source's engine has no span-capable parser. */
| 539 | * Returns -1 when the source's engine has no span-capable parser. |
| 540 | */ |
| 541 | qsizetype DataModel::FrameParser::parseSpansUtf8(const QByteArray& frame, |
| 542 | int sourceId, |
| 543 | QByteArrayView* out, |
| 544 | qsizetype maxSpans) |
| 545 | { |
| 546 | Q_ASSERT(sourceId >= 0); |
| 547 | Q_ASSERT(out != nullptr); |
| 548 | |
| 549 | if (sourceId == 0) [[likely]] { |
| 550 | if (!m_engine0Cache || !m_engine0Cache->isLoaded()) [[unlikely]] |
| 551 | return -1; |
| 552 | |
| 553 | return m_engine0Cache->parseUtf8Spans(QByteArrayView(frame), out, maxSpans); |
| 554 | } |
| 555 | |
| 556 | auto it = m_engines.find(sourceId); |
| 557 | if (it == m_engines.end() || !it->second->isLoaded()) { |
| 558 | if (languageForSource(sourceId) != languageForSource(0)) |
| 559 | return -1; |
| 560 | |
| 561 | return parseSpansUtf8(frame, 0, out, maxSpans); |
| 562 | } |
| 563 | |
| 564 | return it->second->parseUtf8Spans(QByteArrayView(frame), out, maxSpans); |
| 565 | } |
| 566 | |
| 567 | //-------------------------------------------------------------------------------------------------- |
| 568 | // Script loading |
no test coverage detected