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

Function assign_string_in_place

app/src/DataModel/Frame.h:878–887  ·  view source on GitHub ↗

* @brief Allocation-free QString copy: reuses the destination buffer when it is unique and * large enough, falling back to an implicit-share assignment otherwise. */

Source from the content-addressed store, hash-verified

876 * large enough, falling back to an implicit-share assignment otherwise.
877 */
878SS_FORCE_INLINE void assign_string_in_place(QString& dst, const QString& src) noexcept
879{
880 const qsizetype n = src.size();
881 if (dst.isDetached() && dst.capacity() >= n) {
882 dst.resize(n);
883 if (n > 0)
884 memcpy(dst.data(), src.constData(), static_cast<size_t>(n) * sizeof(QChar));
885 } else
886 dst = src;
887}
888
889/**
890 * @brief Writes UTF-8 bytes into a QString, reusing the destination buffer for ASCII payloads. The

Callers 2

applyDatasetValueSpanMethod · 0.85
copy_frame_valuesFunction · 0.85

Calls 4

sizeMethod · 0.45
capacityMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected