| 99 | } |
| 100 | |
| 101 | void ValueVariant::SlowCopyAssign(const ValueVariant& other, bool trivial, |
| 102 | bool other_trivial) noexcept { |
| 103 | ABSL_DCHECK(!trivial || !other_trivial); |
| 104 | |
| 105 | if (trivial) { |
| 106 | switch (other.index_) { |
| 107 | case ValueIndex::kBytes: |
| 108 | ::new (static_cast<void*>(&raw_[0])) |
| 109 | BytesValue(*other.At<BytesValue>()); |
| 110 | break; |
| 111 | case ValueIndex::kString: |
| 112 | ::new (static_cast<void*>(&raw_[0])) |
| 113 | StringValue(*other.At<StringValue>()); |
| 114 | break; |
| 115 | case ValueIndex::kError: |
| 116 | ::new (static_cast<void*>(&raw_[0])) |
| 117 | ErrorValue(*other.At<ErrorValue>()); |
| 118 | break; |
| 119 | case ValueIndex::kUnknown: |
| 120 | ::new (static_cast<void*>(&raw_[0])) |
| 121 | UnknownValue(*other.At<UnknownValue>()); |
| 122 | break; |
| 123 | default: |
| 124 | ABSL_UNREACHABLE(); |
| 125 | } |
| 126 | index_ = other.index_; |
| 127 | kind_ = other.kind_; |
| 128 | flags_ = other.flags_; |
| 129 | } else if (other_trivial) { |
| 130 | switch (index_) { |
| 131 | case ValueIndex::kBytes: |
| 132 | At<BytesValue>()->~BytesValue(); |
| 133 | break; |
| 134 | case ValueIndex::kString: |
| 135 | At<StringValue>()->~StringValue(); |
| 136 | break; |
| 137 | case ValueIndex::kError: |
| 138 | At<ErrorValue>()->~ErrorValue(); |
| 139 | break; |
| 140 | case ValueIndex::kUnknown: |
| 141 | At<UnknownValue>()->~UnknownValue(); |
| 142 | break; |
| 143 | default: |
| 144 | ABSL_UNREACHABLE(); |
| 145 | } |
| 146 | FastCopyAssign(other); |
| 147 | } else { |
| 148 | switch (index_) { |
| 149 | case ValueIndex::kBytes: |
| 150 | switch (other.index_) { |
| 151 | case ValueIndex::kBytes: |
| 152 | *At<BytesValue>() = *other.At<BytesValue>(); |
| 153 | break; |
| 154 | case ValueIndex::kString: |
| 155 | At<BytesValue>()->~BytesValue(); |
| 156 | ::new (static_cast<void*>(&raw_[0])) |
| 157 | StringValue(*other.At<StringValue>()); |
| 158 | index_ = other.index_; |
nothing calls this directly
no test coverage detected