mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 13:29:12 +00:00 
			
		
		
		
	In pool, construct entry_ts in-place and add an rvalue-accepting-and-forwarding insert() method.
				
					
				
			This commit is contained in:
		
							parent
							
								
									2b1fb8c0a0
								
							
						
					
					
						commit
						95b94ad19b
					
				
					 1 changed files with 25 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -745,11 +745,24 @@ protected:
 | 
			
		|||
	int do_insert(const K &value, int &hash)
 | 
			
		||||
	{
 | 
			
		||||
		if (hashtable.empty()) {
 | 
			
		||||
			entries.push_back(entry_t(value, -1));
 | 
			
		||||
			entries.emplace_back(value, -1);
 | 
			
		||||
			do_rehash();
 | 
			
		||||
			hash = do_hash(value);
 | 
			
		||||
		} else {
 | 
			
		||||
			entries.push_back(entry_t(value, hashtable[hash]));
 | 
			
		||||
			entries.emplace_back(value, hashtable[hash]);
 | 
			
		||||
			hashtable[hash] = entries.size() - 1;
 | 
			
		||||
		}
 | 
			
		||||
		return entries.size() - 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	int do_insert(K &&value, int &hash)
 | 
			
		||||
	{
 | 
			
		||||
		if (hashtable.empty()) {
 | 
			
		||||
			entries.emplace_back(std::forward<K>(value), -1);
 | 
			
		||||
			do_rehash();
 | 
			
		||||
			hash = do_hash(value);
 | 
			
		||||
		} else {
 | 
			
		||||
			entries.emplace_back(std::forward<K>(value), hashtable[hash]);
 | 
			
		||||
			hashtable[hash] = entries.size() - 1;
 | 
			
		||||
		}
 | 
			
		||||
		return entries.size() - 1;
 | 
			
		||||
| 
						 | 
				
			
			@ -847,6 +860,16 @@ public:
 | 
			
		|||
		return std::pair<iterator, bool>(iterator(this, i), true);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	std::pair<iterator, bool> insert(K &&value)
 | 
			
		||||
	{
 | 
			
		||||
		int hash = do_hash(value);
 | 
			
		||||
		int i = do_lookup(value, hash);
 | 
			
		||||
		if (i >= 0)
 | 
			
		||||
			return std::pair<iterator, bool>(iterator(this, i), false);
 | 
			
		||||
		i = do_insert(std::forward<K>(value), hash);
 | 
			
		||||
		return std::pair<iterator, bool>(iterator(this, i), true);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	int erase(const K &key)
 | 
			
		||||
	{
 | 
			
		||||
		int hash = do_hash(key);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue