| 85 | } |
| 86 | |
| 87 | void WriteMap::mutate(KeyRef key, MutationRef::Type operation, ValueRef param, bool addConflict) { |
| 88 | writeMapEmpty = false; |
| 89 | auto& it = scratch_iterator; |
| 90 | it.reset(writes, ver); |
| 91 | it.skip(key); |
| 92 | |
| 93 | bool is_cleared = it.entry().following_keys_cleared; |
| 94 | bool following_conflict = it.entry().following_keys_conflict; |
| 95 | bool is_conflict = addConflict || it.is_conflict_range(); |
| 96 | bool following_unreadable = it.entry().following_keys_unreadable; |
| 97 | bool is_unreadable = it.is_unreadable() || operation == MutationRef::SetVersionstampedValue || |
| 98 | operation == MutationRef::SetVersionstampedKey; |
| 99 | bool is_dependent = operation != MutationRef::SetValue && operation != MutationRef::SetVersionstampedValue && |
| 100 | operation != MutationRef::SetVersionstampedKey; |
| 101 | |
| 102 | if (it.entry().key != key) { |
| 103 | if (it.is_cleared_range() && is_dependent) { |
| 104 | it.tree.clear(); |
| 105 | OperationStack op(RYWMutation(Optional<StringRef>(), MutationRef::SetValue)); |
| 106 | coalesceOver(op, RYWMutation(param, operation), *arena); |
| 107 | PTreeImpl::insert( |
| 108 | writes, |
| 109 | ver, |
| 110 | WriteMapEntry( |
| 111 | key, std::move(op), true, following_conflict, is_conflict, following_unreadable, is_unreadable)); |
| 112 | } else { |
| 113 | it.tree.clear(); |
| 114 | PTreeImpl::insert(writes, |
| 115 | ver, |
| 116 | WriteMapEntry(key, |
| 117 | OperationStack(RYWMutation(param, operation)), |
| 118 | is_cleared, |
| 119 | following_conflict, |
| 120 | is_conflict, |
| 121 | following_unreadable, |
| 122 | is_unreadable)); |
| 123 | } |
| 124 | } else { |
| 125 | if (!it.is_unreadable() && |
| 126 | (operation == MutationRef::SetValue || operation == MutationRef::SetVersionstampedValue)) { |
| 127 | it.tree.clear(); |
| 128 | PTreeImpl::remove(writes, ver, key); |
| 129 | PTreeImpl::insert(writes, |
| 130 | ver, |
| 131 | WriteMapEntry(key, |
| 132 | OperationStack(RYWMutation(param, operation)), |
| 133 | is_cleared, |
| 134 | following_conflict, |
| 135 | is_conflict, |
| 136 | following_unreadable, |
| 137 | is_unreadable)); |
| 138 | } else { |
| 139 | WriteMapEntry e(it.entry()); |
| 140 | e.is_conflict = is_conflict; |
| 141 | e.is_unreadable = is_unreadable; |
| 142 | if (e.stack.size() == 0 && it.is_cleared_range() && is_dependent) { |
| 143 | e.stack.push(RYWMutation(Optional<StringRef>(), MutationRef::SetValue)); |
| 144 | coalesceOver(e.stack, RYWMutation(param, operation), *arena); |
nothing calls this directly
no test coverage detected