Skip to content

Commit 5099fdc

Browse files
piaskowykMatiPl01
andauthored
Speedup reanimated build-time (#8226)
## Summary Recently, we've added quite a bit of code that extensively uses templates. Templates significantly influence build times. The core problem was that we had implementations in header files instead of source files. If a header contains implementation, then every compilation unit (each CPP file that includes that file) will compile its own version of the implementation. As a result, we compile the same code multiple times, which significantly increases build time. To address this, this PR moves the implementation from header files to CPP files, effectively compiling them just once. On benchmarks conducted on my machine (macOS, M4, 24GB RAM), I've observed build time improvements of approximately x2 times faster. The results really depend on machine specs, but generally, it seems to be faster. Fixes #8217 --------- Co-authored-by: Mateusz Łopaciński <lop.mateusz.2001@gmail.com>
1 parent 099799e commit 5099fdc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+995
-610
lines changed

packages/react-native-reanimated/Common/cpp/reanimated/CSS/common/definitions.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

33
#include <jsi/jsi.h>
4-
#include <memory>
54
#include <string>
65
#include <vector>
76

packages/react-native-reanimated/Common/cpp/reanimated/CSS/common/transforms/Quaternion.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#pragma once
22

3-
#include <cmath>
4-
53
#ifndef NDEBUG
64
#include <iostream>
75
#endif // NDEBUG

packages/react-native-reanimated/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <reanimated/CSS/common/definitions.h>
44

55
#include <folly/dynamic.h>
6-
#include <memory>
76
#include <string>
87
#include <utility>
98

packages/react-native-reanimated/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix2D.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <reanimated/CSS/common/transforms/vectors.h>
66

77
#include <folly/dynamic.h>
8-
#include <memory>
98
#include <utility>
109

1110
namespace reanimated::css {

packages/react-native-reanimated/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix3D.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include <reanimated/CSS/common/transforms/TransformMatrix3D.h>
22
#include <reanimated/CSS/interpolation/transforms/TransformOperation.h>
33

4+
#include <string>
5+
46
namespace reanimated::css {
57

68
TransformMatrix3D::Decomposed TransformMatrix3D::Decomposed::interpolate(

packages/react-native-reanimated/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix3D.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#include <reanimated/CSS/common/transforms/vectors.h>
77

88
#include <folly/dynamic.h>
9-
#include <memory>
10-
#include <string>
119
#include <utility>
1210

1311
namespace reanimated::css {

packages/react-native-reanimated/Common/cpp/reanimated/CSS/common/transforms/TransformOp.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#include <reanimated/CSS/common/transforms/TransformOp.h>
22

3+
#include <array>
4+
#include <unordered_map>
5+
36
namespace reanimated::css {
47

58
constexpr std::array<const char *, 13> transformOperationStrings = {

packages/react-native-reanimated/Common/cpp/reanimated/CSS/common/transforms/TransformOp.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#pragma once
22

3-
#include <array>
43
#include <string>
5-
#include <unordered_map>
64

75
namespace reanimated::css {
86

packages/react-native-reanimated/Common/cpp/reanimated/CSS/common/transforms/vectors.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#pragma once
22

33
#include <array>
4-
#include <cmath>
5-
#include <string>
6-
#include <unordered_map>
74

85
#ifndef NDEBUG
96
#include <iostream>

packages/react-native-reanimated/Common/cpp/reanimated/CSS/common/values/CSSAngle.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include <reanimated/CSS/common/values/CSSAngle.h>
22

3+
#include <iomanip>
4+
#include <regex>
5+
#include <unordered_map>
6+
37
namespace reanimated::css {
48

59
CSSAngle::CSSAngle() : value(0) {}

0 commit comments

Comments
 (0)