File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -240,8 +240,6 @@ Json::Value obj_value(Json::objectValue); // {}
240
240
241
241
Value& operator =(Value other);
242
242
// / Swap values.
243
- // / \note Currently, comments are intentionally not swapped, for
244
- // / both logic and efficiency.
245
243
void swap (Value& other);
246
244
247
245
ValueType type () const ;
@@ -444,6 +442,9 @@ Json::Value obj_value(Json::objectValue); // {}
444
442
445
443
Value& resolveReference (const char * key, bool isStatic);
446
444
445
+ // / Swap values but leave comments and source offsets in place.
446
+ void swapPayload (Value& other);
447
+
447
448
#ifdef JSON_VALUE_USE_INTERNAL_MAP
448
449
inline bool isItemAvailable () const { return itemIsUsed_ == 0 ; }
449
450
Original file line number Diff line number Diff line change @@ -406,18 +406,23 @@ Value::~Value() {
406
406
}
407
407
408
408
Value& Value::operator =(Value other) {
409
- swap (other);
409
+ swapPayload (other);
410
410
return *this ;
411
411
}
412
412
413
- void Value::swap (Value& other) {
413
+ void Value::swapPayload (Value& other) {
414
414
ValueType temp = type_;
415
415
type_ = other.type_ ;
416
416
other.type_ = temp;
417
417
std::swap (value_, other.value_ );
418
418
int temp2 = allocated_;
419
419
allocated_ = other.allocated_ ;
420
420
other.allocated_ = temp2;
421
+ }
422
+
423
+ void Value::swap (Value& other) {
424
+ swapPayload (other);
425
+ std::swap (comments_, other.comments_ );
421
426
std::swap (start_, other.start_ );
422
427
std::swap (limit_, other.limit_ );
423
428
}
You can’t perform that action at this time.
0 commit comments