Skip to content

Commit

Permalink
Revert D66383921: Change MapPatch::customVisit to use tryPutMulti
Browse files Browse the repository at this point in the history
Differential Revision:
D66383921

Original commit changeset: 429f33a39211

Original Phabricator Diff: D66383921

fbshipit-source-id: d62fe742b9ef6b6ebaf39d27528e42725739ae1b
  • Loading branch information
Mizuchi authored and facebook-github-bot committed Nov 26, 2024
1 parent 239c9ca commit bff4376
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 8 additions & 8 deletions thrift/lib/cpp2/op/detail/ContainerPatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,21 +366,21 @@ class MapPatch : public BaseContainerPatch<Patch, MapPatch<Patch>> {
/// struct Visitor {
/// void assign(const Map&);
/// void clear();
/// void tryPutMulti(const Map&);
/// void putMulti(const Map&);
/// void removeMulti(const std::unordered_set<Key>&);
/// void add(const Map&);
/// void put(const Map&);
/// void remove(const std::unordered_set<Key>&);
/// void patchIfSet(const std::unordered_map<Key, ValuePatch>&);
/// }
///
/// For example:
///
/// MapPatch<MapI32StringPatch> patch;
/// patch.tryPutMulti({{10, "10"}});
/// patch.add({{10, "10"}});
/// patch.ensureAndPatchByKey(20).append("_");
///
/// `patch.customVisit(v)` will invoke the following methods
///
/// v.tryPutMulti({{10, "10"}, {20, ""}});
/// v.add({{10, "10"}, {20, ""}});
/// v.patchIfSet({{20, StringPatch::createAppend("_")}});
template <class Visitor>
void customVisit(Visitor&& v) const {
Expand All @@ -389,7 +389,7 @@ class MapPatch : public BaseContainerPatch<Patch, MapPatch<Patch>> {
v.assign(T{});
v.clear();
v.patchIfSet(P{});
v.tryPutMulti(T{});
v.add(T{});
v.putMulti(T{});
v.removeMulti(std::unordered_set<typename T::key_type>{});
}
Expand All @@ -399,7 +399,7 @@ class MapPatch : public BaseContainerPatch<Patch, MapPatch<Patch>> {
}

v.patchIfSet(*data_.patchPrior());
v.tryPutMulti(*data_.add());
v.add(*data_.add());
v.removeMulti(*data_.remove());
v.putMulti(*data_.put());
v.patchIfSet(*data_.patch());
Expand All @@ -421,7 +421,7 @@ class MapPatch : public BaseContainerPatch<Patch, MapPatch<Patch>> {
void removeMulti(const std::unordered_set<typename T::key_type>& keys) {
erase_all(v, keys);
}
void tryPutMulti(const T& t) { v.insert(t.begin(), t.end()); }
void add(const T& t) { v.insert(t.begin(), t.end()); }
void putMulti(const T& t) {
for (const auto& entry : t) {
v.insert_or_assign(entry.first, entry.second);
Expand Down
2 changes: 0 additions & 2 deletions thrift/lib/cpp2/op/detail/PatchTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ class MinSafePatchVersionVisitor {
template <typename T>
void putMulti(const T&) {}
template <typename T>
void tryPutMulti(const T&) {}
template <typename T>
void remove(const T&) {}
template <typename T>
void removeMulti(const T&) {}
Expand Down

0 comments on commit bff4376

Please sign in to comment.