Skip to content

Commit

Permalink
Use different symbols for SystraceSection depending on WITH_FBYSTRACE
Browse files Browse the repository at this point in the history
Reviewed By: tmikov

Differential Revision: D6365162

fbshipit-source-id: d1e13b0012528305506c368d5e60f3754a576df3
  • Loading branch information
Peter Ammon authored and facebook-github-bot committed Nov 27, 2017
1 parent 028b64b commit 03956c4
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions ReactCommon/cxxreact/SystraceSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,33 @@ namespace react {
* This is a convenience class to avoid lots of verbose profiling
* #ifdefs. If WITH_FBSYSTRACE is not defined, the optimizer will
* remove this completely. If it is defined, it will behave as
* FbSystraceSection, with the right tag provided.
* FbSystraceSection, with the right tag provided. Use two separate classes to
* to ensure that the ODR rule isn't violated, that is, if WITH_FBSYSTRACE has
* different values in different files, there is no inconsistency in the sizes
* of defined symbols.
*/
struct SystraceSection {
#ifdef WITH_FBSYSTRACE
struct ConcreteSystraceSection {
public:
template<typename... ConvertsToStringPiece>
explicit SystraceSection(const char* name, ConvertsToStringPiece&&... args)
#ifdef WITH_FBSYSTRACE
explicit
ConcreteSystraceSection(const char* name, ConvertsToStringPiece&&... args)
: m_section(TRACE_TAG_REACT_CXX_BRIDGE, name, args...)
#endif
{}

private:
#ifdef WITH_FBSYSTRACE
fbsystrace::FbSystraceSection m_section;
#endif
};
using SystraceSection = ConcreteSystraceSection;
#else
struct DummySystraceSection {
public:
template<typename... ConvertsToStringPiece>
explicit
DummySystraceSection(const char* name, ConvertsToStringPiece&&... args)
{}
};
using SystraceSection = DummySystraceSection;
#endif

}}

0 comments on commit 03956c4

Please sign in to comment.