mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-25 20:43:28 +01:00
Avoid copying Clara::Parser for every inserted Opt
This prevents the full construction from being O(N^2) in number of `Opt`s, and also reduces the number of allocations for running no tests significantly: `tests/SelfTest`: 7705 -> 6095 `tests/ExtraTests/NoTests` 2215 -> 605
This commit is contained in:
parent
822c44a203
commit
c57e349d1d
@ -636,8 +636,14 @@ namespace Catch {
|
||||
Parser& operator|=(Parser const& other);
|
||||
|
||||
template <typename T>
|
||||
auto operator|(T const& other) const -> Parser {
|
||||
return Parser(*this) |= other;
|
||||
friend Parser operator|(Parser const& p, T const& rhs) {
|
||||
return Parser( p ) |= rhs;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
friend Parser operator|( Parser&& p, T const& rhs ) {
|
||||
p |= rhs;
|
||||
return CATCH_MOVE(p);
|
||||
}
|
||||
|
||||
std::vector<Detail::HelpColumns> getHelpColumns() const;
|
||||
|
Loading…
Reference in New Issue
Block a user