@@ -13,21 +13,33 @@ namespace react {
13
13
* This is a convenience class to avoid lots of verbose profiling
14
14
* #ifdefs. If WITH_FBSYSTRACE is not defined, the optimizer will
15
15
* 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.
17
20
*/
18
- struct SystraceSection {
21
+ #ifdef WITH_FBSYSTRACE
22
+ struct ConcreteSystraceSection {
19
23
public:
20
24
template <typename ... ConvertsToStringPiece>
21
- explicit SystraceSection ( const char * name, ConvertsToStringPiece&&... args)
22
- # ifdef WITH_FBSYSTRACE
25
+ explicit
26
+ ConcreteSystraceSection ( const char * name, ConvertsToStringPiece&&... args)
23
27
: m_section(TRACE_TAG_REACT_CXX_BRIDGE, name, args...)
24
- #endif
25
28
{}
26
29
27
30
private:
28
- #ifdef WITH_FBSYSTRACE
29
31
fbsystrace::FbSystraceSection m_section;
30
- #endif
31
32
};
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
32
44
33
45
}}
0 commit comments