summaryrefslogtreecommitdiffstats
path: root/src/qjsonparser_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2012-01-17 23:07:42 +0100
committerJamey Hicks <jamey.hicks@nokia.com>2012-01-17 23:26:40 +0100
commitc0598ffc59aad377520008b3078ae6a3d488f35d (patch)
treed9fb2fc5dfad5e3872c319c68b90b8f469e9c88b /src/qjsonparser_p.h
parentd325c361349ce38f5f7dc549dc69f7aae5556069 (diff)
Store the (key, value) pairs in objects sorted
Store the (key, value) pairs in objects in Unicode sort order. This way a key lookup is O(logn) instead of O(n). Make sure the parser stores the parsed results in this order as well. Also make the parser work with duplicate keys (the last entry will be taken, the other ones discarded). Change-Id: Iace9cf5a270620fc9d44e75ee5ed9a77326ab735 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Jamey Hicks <jamey.hicks@nokia.com>
Diffstat (limited to 'src/qjsonparser_p.h')
-rw-r--r--src/qjsonparser_p.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/qjsonparser_p.h b/src/qjsonparser_p.h
index d3700b2..fa08ed5 100644
--- a/src/qjsonparser_p.h
+++ b/src/qjsonparser_p.h
@@ -54,6 +54,7 @@
//
#include <qjsondocument.h>
+#include <qvarlengtharray.h>
namespace QtJson {
@@ -64,6 +65,22 @@ public:
QtJson::QJsonDocument parse();
+ class ParsedObject
+ {
+ public:
+ ParsedObject(QJsonParser *p, int pos) : parser(p), objectPosition(pos) {}
+ void insert(uint offset);
+
+ QJsonParser *parser;
+ int objectPosition;
+ QVarLengthArray<uint> offsets;
+
+ inline Private::Entry *entryAt(int i) const {
+ return reinterpret_cast<Private::Entry *>(parser->data + objectPosition + offsets[i]);
+ }
+ };
+
+
private:
inline bool eatSpace();
inline char nextToken();