addChildren appends attrs to existing fj's attrs.
(fj, head fastJsonNode)
| 361 | |
| 362 | // addChildren appends attrs to existing fj's attrs. |
| 363 | func (enc *encoder) addChildren(fj, head fastJsonNode) { |
| 364 | if fj.child == nil { |
| 365 | fj.child = head |
| 366 | return |
| 367 | } |
| 368 | |
| 369 | tail := head |
| 370 | for tail.next != nil { |
| 371 | tail = tail.next |
| 372 | } |
| 373 | |
| 374 | // We're inserting the node in between. This would need to be fixed later via fixOrder. |
| 375 | // Single child additions: |
| 376 | // Child 1 |
| 377 | // Child 2 -> 1 |
| 378 | // Child 3 -> 2 -> 1 |
| 379 | // Child 4 -> 3 -> 2 -> 1 |
| 380 | // Child 5 -> 4 -> 3 -> 2 -> 1 |
| 381 | // |
| 382 | // If child has siblings, then it could look like this. |
| 383 | // addChildren(13 -> 12 -> 11) |
| 384 | // Child 5 -> 4 -> 3 -> 2 -> 1 |
| 385 | // |
| 386 | // What we want: |
| 387 | // 13 -> 12 -> 11 -> 5 -> 4 -> 3 -> 2 -> 1 |
| 388 | fj.child, tail.next = head, fj.child |
| 389 | } |
| 390 | |
| 391 | // fixOrder would recursively fix the ordering issue caused by addChildren, across the entire |
| 392 | // tree. |
no outgoing calls