From 0fb1774a0aa1b741b0d491b6ac9e63c1b5f8631e Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 15 Jun 2020 14:00:50 +0200 Subject: Simplify QSqlResultPrivate::fieldSerial() Now that the bound values are kept in placeholder order we can depend on that and not have to ensure that fieldSerial() would give us something that is in alphabetical order should it end up being sorted. Change-Id: I3a3e443bef150a06f455e18e3502235b1ae4d242 Reviewed-by: Volker Hilsheimer --- src/sql/kernel/qsqlresult.cpp | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'src') diff --git a/src/sql/kernel/qsqlresult.cpp b/src/sql/kernel/qsqlresult.cpp index 686677a8e7..ecff0a7f2d 100644 --- a/src/sql/kernel/qsqlresult.cpp +++ b/src/sql/kernel/qsqlresult.cpp @@ -58,23 +58,9 @@ QString QSqlResultPrivate::holderAt(int index) const return holders.size() > index ? holders.at(index).holderName : fieldSerial(index); } -// return a unique id for bound names QString QSqlResultPrivate::fieldSerial(int i) const { - char16_t arr[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - auto end = std::end(arr); - auto ptr = end; - - while (i > 0) { - *(--ptr) = 'a' + i % 16; - i >>= 4; - } - - const int nb = end - ptr; - *(--ptr) = 'a' + nb; - *(--ptr) = ':'; - - return QString::fromUtf16(ptr, int(end - ptr)); + return QString(QLatin1String(":%1")).arg(i); } static bool qIsAlnum(QChar ch) -- cgit v1.2.3