mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-03 21:09:12 +00:00 
			
		
		
		
	Get rid of double lookup in TopoSort::node(). This speeds up typical TopoSort time overall by ~10%.
This commit is contained in:
		
							parent
							
								
									6a5799cc2e
								
							
						
					
					
						commit
						bc0df04e06
					
				
					 1 changed files with 5 additions and 8 deletions
				
			
		| 
						 | 
					@ -159,15 +159,12 @@ template <typename T, typename C = std::less<T>, typename OPS = hash_ops<T>> cla
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int node(T n)
 | 
						int node(T n)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		auto it = node_to_index.find(n);
 | 
					                auto rv = node_to_index.emplace(n, static_cast<int>(nodes.size()));
 | 
				
			||||||
		if (it == node_to_index.end()) {
 | 
					                if (rv.second) {
 | 
				
			||||||
                        int index = static_cast<size_t>(nodes.size());
 | 
					      	              nodes.push_back(n);
 | 
				
			||||||
			node_to_index[n] = index;
 | 
							      edges.push_back(std::set<int, IndirectCmp>(indirect_cmp));
 | 
				
			||||||
			nodes.push_back(n);
 | 
					 | 
				
			||||||
			edges.push_back(std::set<int, IndirectCmp>(indirect_cmp));
 | 
					 | 
				
			||||||
			return index;
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return it->second;
 | 
							return rv.first->second;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void edge(int l_index, int r_index) { edges[r_index].insert(l_index); }
 | 
						void edge(int l_index, int r_index) { edges[r_index].insert(l_index); }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue