mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 21:30:04 +00:00 
			
		
		
		
	param_package: Take std::string by value in string-based Set() function
Allows avoiding string copies by letting the strings be moved into the function calls.
This commit is contained in:
		
							parent
							
								
									5b691d3fe0
								
							
						
					
					
						commit
						b92af5a858
					
				
					 2 changed files with 5 additions and 4 deletions
				
			
		|  | @ -3,6 +3,7 @@ | ||||||
| // Refer to the license.txt file included.
 | // Refer to the license.txt file included.
 | ||||||
| 
 | 
 | ||||||
| #include <array> | #include <array> | ||||||
|  | #include <utility> | ||||||
| #include <vector> | #include <vector> | ||||||
| #include "common/logging/log.h" | #include "common/logging/log.h" | ||||||
| #include "common/param_package.h" | #include "common/param_package.h" | ||||||
|  | @ -36,7 +37,7 @@ ParamPackage::ParamPackage(const std::string& serialized) { | ||||||
|             part = Common::ReplaceAll(part, ESCAPE_CHARACTER_ESCAPE, {ESCAPE_CHARACTER}); |             part = Common::ReplaceAll(part, ESCAPE_CHARACTER_ESCAPE, {ESCAPE_CHARACTER}); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         Set(key_value[0], key_value[1]); |         Set(key_value[0], std::move(key_value[1])); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -102,8 +103,8 @@ float ParamPackage::Get(const std::string& key, float default_value) const { | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ParamPackage::Set(const std::string& key, const std::string& value) { | void ParamPackage::Set(const std::string& key, std::string value) { | ||||||
|     data.insert_or_assign(key, value); |     data.insert_or_assign(key, std::move(value)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ParamPackage::Set(const std::string& key, int value) { | void ParamPackage::Set(const std::string& key, int value) { | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ public: | ||||||
|     std::string Get(const std::string& key, const std::string& default_value) const; |     std::string Get(const std::string& key, const std::string& default_value) const; | ||||||
|     int Get(const std::string& key, int default_value) const; |     int Get(const std::string& key, int default_value) const; | ||||||
|     float Get(const std::string& key, float default_value) const; |     float Get(const std::string& key, float default_value) const; | ||||||
|     void Set(const std::string& key, const std::string& value); |     void Set(const std::string& key, std::string value); | ||||||
|     void Set(const std::string& key, int value); |     void Set(const std::string& key, int value); | ||||||
|     void Set(const std::string& key, float value); |     void Set(const std::string& key, float value); | ||||||
|     bool Has(const std::string& key) const; |     bool Has(const std::string& key) const; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue