mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-29 18:52:30 +00:00 
			
		
		
		
	Fixed cstr_buf for std::string with small string optimization
This commit is contained in:
		
							parent
							
								
									3a6abc9bf6
								
							
						
					
					
						commit
						4c733301e6
					
				
					 6 changed files with 16 additions and 5 deletions
				
			
		|  | @ -61,7 +61,7 @@ struct BlifDumper | |||
| 	{ | ||||
| 	} | ||||
| 
 | ||||
| 	std::vector<std::string> cstr_buf; | ||||
| 	vector<shared_str> cstr_buf; | ||||
| 
 | ||||
| 	const char *cstr(RTLIL::IdString id) | ||||
| 	{ | ||||
|  |  | |||
|  | @ -155,7 +155,7 @@ struct BtorDumper | |||
| 		  | ||||
| 	} | ||||
| 	 | ||||
| 	std::vector<std::string> cstr_buf; | ||||
| 	vector<shared_str> cstr_buf; | ||||
| 
 | ||||
| 	const char *cstr(const RTLIL::IdString id) | ||||
| 	{ | ||||
|  |  | |||
|  | @ -52,7 +52,7 @@ string log_last_error; | |||
| 
 | ||||
| vector<int> header_count; | ||||
| pool<RTLIL::IdString> log_id_cache; | ||||
| vector<string> string_buf; | ||||
| vector<shared_str> string_buf; | ||||
| int string_buf_index = -1; | ||||
| 
 | ||||
| static struct timeval initial_tv = { 0, 0 }; | ||||
|  |  | |||
|  | @ -140,6 +140,17 @@ using std::vector; | |||
| using std::string; | ||||
| using std::pair; | ||||
| 
 | ||||
| // A primitive shared string implementation that does not
 | ||||
| // move its .c_str() when the object is copied or moved.
 | ||||
| struct shared_str { | ||||
| 	std::shared_ptr<string> content; | ||||
| 	shared_str() { } | ||||
| 	shared_str(string s) { content = std::shared_ptr<string>(new string(s)); } | ||||
| 	shared_str(const char *s) { content = std::shared_ptr<string>(new string(s)); } | ||||
| 	const char *c_str() { return content->c_str(); } | ||||
| 	const string &str() { return *content; } | ||||
| }; | ||||
| 
 | ||||
| using hashlib::mkhash; | ||||
| using hashlib::mkhash_init; | ||||
| using hashlib::mkhash_add; | ||||
|  |  | |||
|  | @ -41,7 +41,7 @@ struct ShowWorker | |||
| { | ||||
| 	CellTypes ct; | ||||
| 
 | ||||
| 	std::vector<std::string> dot_escape_store; | ||||
| 	vector<shared_str> dot_escape_store; | ||||
| 	std::map<RTLIL::IdString, int> dot_id2num_store; | ||||
| 	std::map<RTLIL::IdString, int> autonames; | ||||
| 	int single_idx_count; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue