Skip to content

Commit 03956c4

Browse files
Peter Ammonfacebook-github-bot
Peter Ammon
authored andcommittedNov 27, 2017
Use different symbols for SystraceSection depending on WITH_FBYSTRACE
Reviewed By: tmikov Differential Revision: D6365162 fbshipit-source-id: d1e13b0012528305506c368d5e60f3754a576df3
1 parent 028b64b commit 03956c4

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed
 

Diff for: ‎ReactCommon/cxxreact/SystraceSection.h

+19-7
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,33 @@ namespace react {
1313
* This is a convenience class to avoid lots of verbose profiling
1414
* #ifdefs. If WITH_FBSYSTRACE is not defined, the optimizer will
1515
* remove this completely. If it is defined, it will behave as
16-
* FbSystraceSection, with the right tag provided.
16+
* FbSystraceSection, with the right tag provided. Use two separate classes to
17+
* to ensure that the ODR rule isn't violated, that is, if WITH_FBSYSTRACE has
18+
* different values in different files, there is no inconsistency in the sizes
19+
* of defined symbols.
1720
*/
18-
struct SystraceSection {
21+
#ifdef WITH_FBSYSTRACE
22+
struct ConcreteSystraceSection {
1923
public:
2024
template<typename... ConvertsToStringPiece>
21-
explicit SystraceSection(const char* name, ConvertsToStringPiece&&... args)
22-
#ifdef WITH_FBSYSTRACE
25+
explicit
26+
ConcreteSystraceSection(const char* name, ConvertsToStringPiece&&... args)
2327
: m_section(TRACE_TAG_REACT_CXX_BRIDGE, name, args...)
24-
#endif
2528
{}
2629

2730
private:
28-
#ifdef WITH_FBSYSTRACE
2931
fbsystrace::FbSystraceSection m_section;
30-
#endif
3132
};
33+
using SystraceSection = ConcreteSystraceSection;
34+
#else
35+
struct DummySystraceSection {
36+
public:
37+
template<typename... ConvertsToStringPiece>
38+
explicit
39+
DummySystraceSection(const char* name, ConvertsToStringPiece&&... args)
40+
{}
41+
};
42+
using SystraceSection = DummySystraceSection;
43+
#endif
3244

3345
}}

0 commit comments

Comments
 (0)
Please sign in to comment.