Skip to content

Commit

Permalink
Re-use safePatchVersionVisitor
Browse files Browse the repository at this point in the history
Summary: we can re-use the same visitor instead of creating local.

Reviewed By: Mizuchi

Differential Revision: D70584961

fbshipit-source-id: 4abc6933bae63b4fe5276aa9d0409e5cb5a65654
  • Loading branch information
thedavekwon authored and facebook-github-bot committed Mar 5, 2025
1 parent db47d52 commit a5b2733
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions third-party/thrift/src/thrift/lib/thrift/detail/DynamicPatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1649,34 +1649,18 @@ class MinSafePatchVersionVisitor {
patch.visitPatch(
badge,
folly::overload(
[&](const DynamicMapPatch& p) {
MinSafePatchVersionVisitor visitor;
p.customVisit(badge, visitor);
version = std::max(version, visitor.version);
},
[&](const DynamicStructPatch& p) {
MinSafePatchVersionVisitor visitor;
p.customVisit(badge, visitor);
version = std::max(version, visitor.version);
},
[&](const DynamicUnionPatch& p) {
MinSafePatchVersionVisitor visitor;
p.customVisit(badge, visitor);
version = std::max(version, visitor.version);
},
[&](const DynamicMapPatch& p) { p.customVisit(badge, *this); },
[&](const DynamicStructPatch& p) { p.customVisit(badge, *this); },
[&](const DynamicUnionPatch& p) { p.customVisit(badge, *this); },
[&](const op::AnyPatch& p) {
// recurse AnyPatch in case it only uses `assign` or `clear`
// operations that are V1.
MinSafePatchVersionVisitor visitor;
p.customVisit(visitor);
version = std::max(version, visitor.version);
p.customVisit(*this);
},
[&](const DynamicUnknownPatch& p) {
// recurse DynamicUnknownPatch for `patchPrior/patchAfter` in
// `StructuredOrAnyPatch`.
MinSafePatchVersionVisitor visitor;
p.customVisit(badge, visitor);
version = std::max(version, visitor.version);
p.customVisit(badge, *this);
},
[&](const auto&) {
// Short circuit all other patch types.
Expand Down

0 comments on commit a5b2733

Please sign in to comment.