File tree Expand file tree Collapse file tree 1 file changed +16
-20
lines changed Expand file tree Collapse file tree 1 file changed +16
-20
lines changed Original file line number Diff line number Diff line change @@ -22,17 +22,14 @@ class JsonSerializer : public VariantDataVisitor<size_t> {
22
22
size_t visitArray (const VariantImpl& array) {
23
23
write (' [' );
24
24
25
- auto slotId = array. head () ;
25
+ bool first = true ;
26
26
27
- while (slotId != NULL_SLOT) {
28
- auto slot = resources_->getVariant (slotId);
29
-
30
- VariantImpl (slot, resources_).accept (*this );
31
-
32
- slotId = slot->next ;
33
-
34
- if (slotId != NULL_SLOT)
27
+ for (auto it = array.createIterator (); !it.done (); it.move ()) {
28
+ if (!first)
35
29
write (' ,' );
30
+
31
+ it->accept (*this );
32
+ first = false ;
36
33
}
37
34
38
35
write (' ]' );
@@ -42,20 +39,19 @@ class JsonSerializer : public VariantDataVisitor<size_t> {
42
39
size_t visitObject (const VariantImpl& object) {
43
40
write (' {' );
44
41
45
- auto slotId = object.head ();
42
+ bool first = true ;
43
+ bool isValue = false ;
46
44
47
- bool isKey = true ;
48
-
49
- while (slotId != NULL_SLOT) {
50
- auto slot = resources_->getVariant (slotId);
51
- VariantImpl (slot, resources_).accept (*this );
52
-
53
- slotId = slot->next ;
45
+ for (auto it = object.createIterator (); !it.done (); it.move ()) {
46
+ if (isValue)
47
+ write (' :' );
48
+ else if (!first)
49
+ write (' ,' );
54
50
55
- if (slotId != NULL_SLOT)
56
- write (isKey ? ' :' : ' ,' );
51
+ it->accept (*this );
57
52
58
- isKey = !isKey;
53
+ first = false ;
54
+ isValue = !isValue;
59
55
}
60
56
61
57
write (' }' );
You can’t perform that action at this time.
0 commit comments