diff options
author | Christian Ehrlicher <[email protected]> | 2024-06-06 17:34:56 +0200 |
---|---|---|
committer | Christian Ehrlicher <[email protected]> | 2024-06-07 17:31:30 +0200 |
commit | e623f038f7738c202e745f693458ccb81f9484b6 (patch) | |
tree | 9c9c70e2e24401e22457b0b600dbc288babee425 /src/plugins/sqldrivers/ibase/qsql_ibase.cpp | |
parent | fc4750bd753999e9a0787614ac8960e0506075dd (diff) |
SQL/IBase: code cleanup part 3/5
Pass 'const char *' when the string doesn't get modified.
Pick-to: 6.8
Change-Id: I8b2e06b027362debcd81282dc3123235a7e643a3
Reviewed-by: Axel Spoerl <[email protected]>
Diffstat (limited to 'src/plugins/sqldrivers/ibase/qsql_ibase.cpp')
-rw-r--r-- | src/plugins/sqldrivers/ibase/qsql_ibase.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp index 92aa77f210e..ea836ca94b3 100644 --- a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp +++ b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp @@ -240,7 +240,7 @@ static ISC_TIMESTAMP toTimeStamp(const QDateTime &dt) return ts; } -static QDateTime fromTimeStamp(char *buffer) +static QDateTime fromTimeStamp(const char *buffer) { static const QDate bd(1858, 11, 17); QTime t(0, 0); @@ -248,14 +248,14 @@ static QDateTime fromTimeStamp(char *buffer) // have to demangle the structure ourselves because isc_decode_time // strips the msecs - auto timebuf = reinterpret_cast<ISC_TIMESTAMP*>(buffer); + auto timebuf = reinterpret_cast<const ISC_TIMESTAMP *>(buffer); t = t.addMSecs(static_cast<int>(timebuf->timestamp_time / 10)); d = bd.addDays(timebuf->timestamp_date); return QDateTime(d, t); } #if (FB_API_VER >= 40) -QDateTime fromTimeStampTz(char *buffer) +QDateTime fromTimeStampTz(const char *buffer) { static const QDate bd(1858, 11, 17); QTime t(0, 0); @@ -263,7 +263,7 @@ QDateTime fromTimeStampTz(char *buffer) // have to demangle the structure ourselves because isc_decode_time // strips the msecs - auto timebuf = reinterpret_cast<ISC_TIMESTAMP_TZ*>(buffer); + auto timebuf = reinterpret_cast<const ISC_TIMESTAMP_TZ *>(buffer); t = t.addMSecs(static_cast<int>(timebuf->utc_timestamp.timestamp_time / 10)); d = bd.addDays(timebuf->utc_timestamp.timestamp_date); quint16 fpTzID = timebuf->time_zone; @@ -293,12 +293,13 @@ static ISC_TIME toTime(QTime t) return (ISC_TIME)midnight.msecsTo(t) * 10; } -static QTime fromTime(char *buffer) +static QTime fromTime(const char *buffer) { QTime t(0, 0); // have to demangle the structure ourselves because isc_decode_time // strips the msecs - t = t.addMSecs(int((*(ISC_TIME*)buffer) / 10)); + const auto timebuf = reinterpret_cast<const ISC_TIME *>(buffer); + t = t.addMSecs(int((*timebuf) / 10)); return t; } @@ -312,14 +313,15 @@ static ISC_DATE toDate(QDate t) return date; } -static QDate fromDate(char *buffer) +static QDate fromDate(const char *buffer) { static const QDate bd(1858, 11, 17); QDate d; // have to demangle the structure ourselves because isc_decode_time // strips the msecs - d = bd.addDays(int(((ISC_TIMESTAMP*)buffer)->timestamp_date)); + const auto tsbuf = reinterpret_cast<const ISC_TIMESTAMP *>(buffer); + d = bd.addDays(int(tsbuf->timestamp_date)); return d; } @@ -620,9 +622,10 @@ QVariant QIBaseResultPrivate::fetchBlob(ISC_QUAD *bId) } template<typename T> -static QList<QVariant> toList(char** buf, int count) +static QList<QVariant> toList(const char **buf, int count) { QList<QVariant> res; + res.reserve(count); for (int i = 0; i < count; ++i) { res.append(*(T*)(*buf)); *buf += sizeof(T); @@ -630,8 +633,8 @@ static QList<QVariant> toList(char** buf, int count) return res; } -static char* readArrayBuffer(QList<QVariant>& list, char *buffer, short curDim, - short* numElements, ISC_ARRAY_DESC *arrayDesc) +static const char *readArrayBuffer(QList<QVariant>& list, const char *buffer, short curDim, + const short *numElements, ISC_ARRAY_DESC *arrayDesc) { const short dim = arrayDesc->array_desc_dimensions - 1; const unsigned char dataType = arrayDesc->array_desc_dtype; @@ -1307,7 +1310,7 @@ bool QIBaseResult::gotoNext(QSqlCachedResult::ValueCache& row, int rowIdx) continue; } - char *buf = sqlvar.sqldata; + const char *buf = sqlvar.sqldata; int size = sqlvar.sqllen; Q_ASSERT(buf); const auto sqltype = sqlvar.sqltype & ~1; |