File tree Expand file tree Collapse file tree 3 files changed +22
-15
lines changed
Expand file tree Collapse file tree 3 files changed +22
-15
lines changed Original file line number Diff line number Diff line change 55----
66
77* Improve error messages when using ` char ` or ` char* ` (issue #2043 )
8+ * Reduce ` serializeJson() ` 's size and stack usage (issue #2046 )
89
910v7.0.2 (2024-01-19)
1011------
Original file line number Diff line number Diff line change @@ -107,6 +107,10 @@ class CollectionData {
107107 return collection->remove (it, resources);
108108 }
109109
110+ SlotId head () const {
111+ return head_;
112+ }
113+
110114 protected:
111115 iterator addSlot (ResourceManager*);
112116
Original file line number Diff line number Diff line change @@ -22,16 +22,17 @@ class JsonSerializer : public VariantDataVisitor<size_t> {
2222 FORCE_INLINE size_t visit (const ArrayData& array) {
2323 write (' [' );
2424
25- auto it = array.createIterator (resources_ );
25+ auto slotId = array.head ( );
2626
27- while (!it. done () ) {
28- it-> accept (* this );
27+ while (slotId != NULL_SLOT ) {
28+ auto slot = resources_-> getSlot (slotId );
2929
30- it.next (resources_);
31- if (it.done ())
32- break ;
30+ slot->data ()->accept (*this );
3331
34- write (' ,' );
32+ slotId = slot->next ();
33+
34+ if (slotId != NULL_SLOT)
35+ write (' ,' );
3536 }
3637
3738 write (' ]' );
@@ -41,18 +42,19 @@ class JsonSerializer : public VariantDataVisitor<size_t> {
4142 size_t visit (const ObjectData& object) {
4243 write (' {' );
4344
44- auto it = object.createIterator (resources_);
45+ auto slotId = object.head ();
46+
47+ while (slotId != NULL_SLOT) {
48+ auto slot = resources_->getSlot (slotId);
4549
46- while (!it.done ()) {
47- formatter_.writeString (it.key ());
50+ formatter_.writeString (slot->key ());
4851 write (' :' );
49- it ->accept (*this );
52+ slot-> data () ->accept (*this );
5053
51- it.next (resources_);
52- if (it.done ())
53- break ;
54+ slotId = slot->next ();
5455
55- write (' ,' );
56+ if (slotId != NULL_SLOT)
57+ write (' ,' );
5658 }
5759
5860 write (' }' );
You can’t perform that action at this time.
0 commit comments