summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qbytearray.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/text/qbytearray.cpp')
-rw-r--r--src/corelib/text/qbytearray.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp
index 9a72df58d3..b59979664c 100644
--- a/src/corelib/text/qbytearray.cpp
+++ b/src/corelib/text/qbytearray.cpp
@@ -1274,7 +1274,7 @@ QByteArray &QByteArray::operator=(const char *str)
functions that expect '\\0'-terminated strings. If the QByteArray object
was created from a \l{fromRawData()}{raw data} that didn't include the
trailing null-termination character then QByteArray doesn't add it
- automaticall unless the \l{deep copy} is created.
+ automatically unless the \l{deep copy} is created.
Example:
\snippet code/src_corelib_tools_qbytearray.cpp 6
@@ -4148,19 +4148,21 @@ QByteArray QByteArray::toBase64(Base64Options options) const
const char padchar = '=';
int padlen = 0;
- QByteArray tmp((d->size + 2) / 3 * 4, Qt::Uninitialized);
+ const int sz = size();
+
+ QByteArray tmp((sz + 2) / 3 * 4, Qt::Uninitialized);
int i = 0;
char *out = tmp.data();
- while (i < d->size) {
+ while (i < sz) {
// encode 3 bytes at a time
int chunk = 0;
chunk |= int(uchar(d->data()[i++])) << 16;
- if (i == d->size) {
+ if (i == sz) {
padlen = 2;
} else {
chunk |= int(uchar(d->data()[i++])) << 8;
- if (i == d->size)
+ if (i == sz)
padlen = 1;
else
chunk |= int(uchar(data()[i++]));