types: share Function payload on copy - #255
Conversation
aea1d63 to
c542559
Compare
|
Review (cannot request-changes on our own PR) The share belongs on The pimpl already bought something this patch does not use.
Store values in struct Function::Impl {
Type returnType;
std::vector<Type> arguments;
bool variadic { false };
};Then:
The public ctor can keep taking That is the same change, with the incidental heap shape deleted. I would not merge the unique_ptr-in-Impl version. |
|
Tick the box to add this pull request to the merge queue (same as
|
Pointer, array, and record payloads already share. Function was the odd one: every Type copy deep-cloned the return type and arguments. Function is immutable after construction, so copies can share. Analyze on a full git -O0 build went 49s -> 40s (user 224s -> 209s).
Impl lives in the .cpp, so it can hold Type by value. unique_ptr was only needed in the header to break the Type include cycle. Accessors now return const refs; the public ctor still takes unique_ptr.
cbb7d6b to
c88cf04
Compare
Summary
Functioncopies now share an immutable impl (shared_ptr) instead of deep-cloning the return type and every argument.Typecopy.Functionhas no setters.Isolated measure on this machine (Release, git
-O0, 568 TUs): analyze 49s -> 40s, full user 224s -> 209s.diff.canalyze 96ms -> 80ms.Test plan
ctest -R '^(typesTest|astTest|symbolsTest|semantic_analyzerTest)$'ctest -L att -j24