summaryrefslogtreecommitdiffstats
path: root/src/plugins/sqldrivers/mimer/qsql_mimer.cpp
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2024-10-23 19:47:28 +0200
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2024-11-05 00:13:55 +0200
commit814e4e1cbe6e4a625625942c70b394aa6455fb19 (patch)
treec1dd837f60d6cc09618b7cd1b8b4b7a181b61247 /src/plugins/sqldrivers/mimer/qsql_mimer.cpp
parentcfc80488d1b3ceec939a29951b017cae26a31ab6 (diff)
SQL/Mimer: simplify uuid conversion
Simplify converting a QUuid to a rfc4122 representation by using the built-in toRfc4122() function and don't allocate a temporary QByteArray when converting it back from rfc4122 to a QUuid. As a drive-by make sure to not detach when converting a QByteArray to a blob. Pick-to: 6.8 Change-Id: Ib8fc7744952377d14ef39c0d901a6a8419eb018d Reviewed-by: Fredrik Ă…lund <fredrik.alund@mimer.com> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'src/plugins/sqldrivers/mimer/qsql_mimer.cpp')
-rw-r--r--src/plugins/sqldrivers/mimer/qsql_mimer.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/plugins/sqldrivers/mimer/qsql_mimer.cpp b/src/plugins/sqldrivers/mimer/qsql_mimer.cpp
index 384874f8d97..ef2c9e0f95b 100644
--- a/src/plugins/sqldrivers/mimer/qsql_mimer.cpp
+++ b/src/plugins/sqldrivers/mimer/qsql_mimer.cpp
@@ -845,7 +845,7 @@ QVariant QMimerSQLResult::data(int i)
err, QSqlError::StatementError, d->drv_d_func()));
return QVariant(QMetaType(type), nullptr);
}
- const QByteArray uuidByteArray = QByteArray(reinterpret_cast<char *>(uuidChar), 16);
+ const auto uuidByteArray = QByteArrayView(reinterpret_cast<char *>(uuidChar), 16);
return QUuid::fromRfc4122(uuidByteArray);
}
case MimerColumnTypes::Unknown:
@@ -1084,8 +1084,7 @@ bool QMimerSQLResult::exec()
break;
}
case MimerColumnTypes::Uuid: {
- const QByteArray uuidArray =
- QByteArray::fromHex(val.toUuid().toString(QUuid::WithoutBraces).toLatin1());
+ const QByteArray uuidArray = val.toUuid().toRfc4122();
const unsigned char *uuid =
reinterpret_cast<const unsigned char *>(uuidArray.constData());
err = MimerSetUUID(d->statementhandle, i + 1, uuid);
@@ -1152,7 +1151,7 @@ bool QMimerSQLResult::exec()
break;
}
case MimerColumnTypes::Blob: {
- QByteArray blobArr = val.toByteArray();
+ const QByteArray blobArr = val.toByteArray();
const char *blobData = blobArr.constData();
qsizetype size = blobArr.size();
err = MimerSetLob(d->statementhandle, i + 1, size, &d->lobhandle);