rcc: Avoid needless use of macro
strlen on literals gets typically optimized out nowadays. Adjust callee side to handle the off-by-one between sizeof(literal) and strlen(). Change-Id: I1551f69a160922681d66024701ba1bd8f6dc03bf Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
242bc539ab
commit
166753d8e0
@ -67,11 +67,8 @@ enum {
|
||||
# define CONSTANT_COMPRESSALGO_DEFAULT RCCResourceLibrary::CompressionAlgorithm::None
|
||||
#endif
|
||||
|
||||
#define writeString(s) write(s, sizeof(s))
|
||||
|
||||
void RCCResourceLibrary::write(const char *str, int len)
|
||||
{
|
||||
--len; // trailing \0 on string literals...
|
||||
int n = m_out.size();
|
||||
m_out.resize(n + len);
|
||||
memcpy(m_out.data() + n, str, len);
|
||||
@ -983,7 +980,7 @@ void RCCResourceLibrary::writeDecimal(int value)
|
||||
Q_ASSERT(m_format != RCCResourceLibrary::Binary);
|
||||
char buf[std::numeric_limits<int>::digits10 + 2];
|
||||
int n = snprintf(buf, sizeof(buf), "%d", value);
|
||||
write(buf, n + 1); // write() takes a size including terminating NUL
|
||||
write(buf, n);
|
||||
}
|
||||
|
||||
static const char hexDigits[] = "0123456789abcdef";
|
||||
|
@ -143,6 +143,7 @@ private:
|
||||
void writeChar(char c) { m_out.append(c); }
|
||||
void writeByteArray(const QByteArray &);
|
||||
void write(const char *, int len);
|
||||
void writeString(const char *s) { write(s, static_cast<int>(strlen(s))); }
|
||||
|
||||
#if QT_CONFIG(zstd)
|
||||
ZSTD_CCtx *m_zstdCCtx;
|
||||
|
Loading…
x
Reference in New Issue
Block a user