diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2012-01-07 17:35:53 +0100 |
---|---|---|
committer | Jamey Hicks <jamey.hicks@nokia.com> | 2012-01-09 12:25:19 +0100 |
commit | 21777c47da86d4e7207ee474e7a7a14a294aa35f (patch) | |
tree | c1c79ec5776e74a34c576e6ee83bbeb084e3a821 /src | |
parent | 7ef5aa21ace014cccc94420ba7624f2f0477bf1c (diff) |
Store double as little endian
Change-Id: I0eaa94c61124f710d4b9db26cbe08b483b64700b
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Reviewed-by: Jamey Hicks <jamey.hicks@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qjson_p.h | 4 | ||||
-rw-r--r-- | src/qjsonvalue.cpp | 5 | ||||
-rw-r--r-- | src/qjsonvalue.h | 1 |
3 files changed, 6 insertions, 4 deletions
diff --git a/src/qjson_p.h b/src/qjson_p.h index 06883fc..6cbf53d 100644 --- a/src/qjson_p.h +++ b/src/qjson_p.h @@ -533,10 +533,10 @@ inline double Value::toNumber(const Base *b) const return int_val; union { - char raw[sizeof(double)]; + quint64 i; double d; }; - memcpy(raw, ((char *)b + val), sizeof(double)); + i = qFromLittleEndian<quint64>((const uchar *)b + val); return d; } diff --git a/src/qjsonvalue.cpp b/src/qjsonvalue.cpp index dcf7a5f..07d043c 100644 --- a/src/qjsonvalue.cpp +++ b/src/qjsonvalue.cpp @@ -415,8 +415,9 @@ void JsonValue::copyData(char *dest, bool compressed) const { switch (t) { case NumberValue: - if (!compressed) - memcpy(dest, raw, sizeof(dbl)); + if (!compressed) { + *((quint64 *)dest) = qToLittleEndian(ui); + } break; case StringValue: { QString str = toString(); diff --git a/src/qjsonvalue.h b/src/qjsonvalue.h index 55d2e14..611cf76 100644 --- a/src/qjsonvalue.h +++ b/src/qjsonvalue.h @@ -106,6 +106,7 @@ private: Data *d; // needed for Objects and Arrays union { char raw[sizeof(double)]; + quint64 ui; bool b; double dbl; QStringData *stringData; |