diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2011-12-08 10:34:43 +0100 |
---|---|---|
committer | Simons Kevin <kevin.simons@nokia.com> | 2011-12-08 15:28:31 +0100 |
commit | a9d3828eebe4c11473b8933948c4e711dab25659 (patch) | |
tree | a7e3c48552248329057438519a4f86dcd6464d82 | |
parent | a352643165b7d015695747fc31e60983c336d783 (diff) |
Save another 4 bytes per object and array
There's no requirement to align to 8 byte
boundaries anymore, as we now allow doubles
to be unaligned. Thus the 4 byte hole
in the data structure can be removed.
Change-Id: I598272af69d96384a195510e7254bf47d50b1b00
Reviewed-by: Simons Kevin <kevin.simons@nokia.com>
-rw-r--r-- | src/qjson_p.h | 13 | ||||
-rw-r--r-- | src/qjsonarray.cpp | 1 | ||||
-rw-r--r-- | src/qjsondocument.cpp | 2 | ||||
-rw-r--r-- | src/qjsonobject.cpp | 1 | ||||
-rw-r--r-- | src/qjsonvalue.cpp | 2 |
5 files changed, 7 insertions, 12 deletions
diff --git a/src/qjson_p.h b/src/qjson_p.h index 42f0d1a..a832d97 100644 --- a/src/qjson_p.h +++ b/src/qjson_p.h @@ -29,29 +29,29 @@ For an example such as - { // object: 16 + 5*12 = 72 + { // object: 12 + 5*12 = 72 "firstName": "John", // key 4+12, value 8 = 24 "lastName" : "Smith", // key 4+8, value 8 = 20 "age" : 25, // key 4+4, value 0 = 8 "address" : // key 4+8, object below = 160 - { // object: 16 + 4*12 + { // object: 12 + 4*12 "streetAddress": "21 2nd Street", // key 4+16, value 16 "city" : "New York", // key 4+4, value 12 "state" : "NY", // key 4+8, value 4 "postalCode" : "10021" // key 4+12, value 8 }, // object total: 148 "phoneNumber": // key: 4+12, value array below = 208 - [ // array: 16 + 2*4 + values below = 192 - { // object 16 + 2*12 + [ // array: 12 + 2*4 + values below = 192 + { // object 12 + 2*12 "type" : "home", // key 4+4, value 8 "number": "212 555-1234" // key 4+8, value 16 }, // object total: 84 - { // object 16 + 2*12 + { // object 12 + 2*12 "type" : "fax", // key 4+4, value 8 "number": "646 555-4567" // key 4+8, value 16 } // object total: 84 ] // array total: 248 - } // great total: 492 bytes + } // great total: 472 bytes The uncompressed text file used roughly 500 bytes, so we end up using about the same space as the text representation. @@ -228,7 +228,6 @@ struct Base { uint size; uint length; - uint unused; offset tableOffset; // content follows here diff --git a/src/qjsonarray.cpp b/src/qjsonarray.cpp index b9a0dd2..78ab35b 100644 --- a/src/qjsonarray.cpp +++ b/src/qjsonarray.cpp @@ -211,7 +211,6 @@ void JsonArray::detach(uint reserve) int alloc = sizeof(Array) + reserve + sizeof(offset); a = (Array *)malloc(alloc); a->size = sizeof(Array); - a->unused = 0; a->tableOffset = sizeof(Array); a->length = 0; d = new Data((char *)a, alloc); diff --git a/src/qjsondocument.cpp b/src/qjsondocument.cpp index 4900f1c..415b315 100644 --- a/src/qjsondocument.cpp +++ b/src/qjsondocument.cpp @@ -173,7 +173,6 @@ void JsonDocument::setObject(const JsonObject &object) } else { h->root.size = sizeof(Base); h->root.length = 0; - h->root.unused = 0; h->root.tableOffset = 0; } @@ -196,7 +195,6 @@ void JsonDocument::setArray(const JsonArray &array) } else { h->root.size = sizeof(Base); h->root.length = 0; - h->root.unused = 0; h->root.tableOffset = 0; } diff --git a/src/qjsonobject.cpp b/src/qjsonobject.cpp index 209a5d7..f55701f 100644 --- a/src/qjsonobject.cpp +++ b/src/qjsonobject.cpp @@ -274,7 +274,6 @@ void JsonObject::detach(uint reserve) int alloc = sizeof(Array) + reserve + sizeof(offset); o = (Object *)malloc(alloc); o->size = sizeof(Object); - o->unused = 0; o->tableOffset = sizeof(Object); o->length = 0; d = new Data((char *)o, alloc); diff --git a/src/qjsonvalue.cpp b/src/qjsonvalue.cpp index 0028728..bc5a626 100644 --- a/src/qjsonvalue.cpp +++ b/src/qjsonvalue.cpp @@ -10,7 +10,7 @@ using namespace QtJson; -static const Base emptyBase = { sizeof(Base), 0, 0, 0 }; +static const Base emptyBase = { sizeof(Base), 0, 0 }; JsonValue::JsonValue(ValueType type) : t(type), d(0), dbl(0.) |