mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-11-04 14:09:33 +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:
		@@ -636,8 +636,14 @@ namespace Catch {
 | 
				
			|||||||
            Parser& operator|=(Parser const& other);
 | 
					            Parser& operator|=(Parser const& other);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            template <typename T>
 | 
					            template <typename T>
 | 
				
			||||||
            auto operator|(T const& other) const -> Parser {
 | 
					            friend Parser operator|(Parser const& p, T const& rhs) {
 | 
				
			||||||
                return Parser(*this) |= other;
 | 
					                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;
 | 
					            std::vector<Detail::HelpColumns> getHelpColumns() const;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user