Skip to content

Commit 7f644fe

Browse files
TJ Yinfacebook-github-bot
TJ Yin
authored andcommitted
Extern "apply(...)" and "merge(...)" methods in "StructPatch" and "UnionPatch"
Summary: They are expensive to build, let's explicitly instantiate them. Reviewed By: thedavekwon Differential Revision: D72946822 fbshipit-source-id: b6f560d8fe06bb4b730dbddb691cdf2a90d3549e
1 parent 08b7d64 commit 7f644fe

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

Diff for: thrift/lib/cpp2/op/detail/StructPatch.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ class BaseEnsurePatch : public BaseClearPatch<Patch, Derived> {
508508
}
509509
}
510510

511-
void apply(T& val) const { return customVisit(Applier{val}); }
511+
void apply(T& val) const;
512512

513513
/**
514514
* Returns a Thrift Patch instance corresponding to the (decoded) `SafePatch`.
@@ -770,6 +770,9 @@ class StructPatch : public BaseEnsurePatch<Patch, StructPatch<Patch>> {
770770
}
771771
/// @endcond
772772

773+
void merge(const StructPatch& patch);
774+
void merge(StructPatch&& patch);
775+
773776
private:
774777
using Base::data_;
775778

@@ -844,6 +847,9 @@ class UnionPatch : public BaseEnsurePatch<Patch, UnionPatch<Patch>> {
844847
void assign(U&& val) {
845848
op::get<Id>(Base::resetAnd().assign().ensure()) = std::forward<U>(val);
846849
}
850+
851+
void merge(const UnionPatch& patch);
852+
void merge(UnionPatch&& patch);
847853
};
848854

849855
} // namespace apache::thrift::op::detail

Diff for: thrift/lib/cpp2/op/detail/StructPatchImpl.h

+21
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,25 @@ auto BaseEnsurePatch<Patch, Derived>::patchImpl() -> patch_type& {
3737
"Field (id={}) is not patchable", folly::to_underlying(FieldId::value));
3838
}
3939
}
40+
41+
template <class Patch, class Derived>
42+
void BaseEnsurePatch<Patch, Derived>::apply(T& val) const {
43+
return customVisit(Applier{val});
44+
}
45+
template <class Patch>
46+
void StructPatch<Patch>::merge(const StructPatch& val) {
47+
Base::merge(val);
48+
}
49+
template <class Patch>
50+
void StructPatch<Patch>::merge(StructPatch&& val) {
51+
Base::merge(std::move(val));
52+
}
53+
template <class Patch>
54+
void UnionPatch<Patch>::merge(const UnionPatch& val) {
55+
Base::merge(val);
56+
}
57+
template <class Patch>
58+
void UnionPatch<Patch>::merge(UnionPatch&& val) {
59+
Base::merge(std::move(val));
60+
}
4061
} // namespace apache::thrift::op::detail

0 commit comments

Comments
 (0)