forked from OSchip/llvm-project
				
			Add a new version of Module::getFunction that takes a const char* instead
of a std::string. This avoids copying the string to the heap in common cases. Patch by Pratik Solanki! llvm-svn: 52834
This commit is contained in:
		
							parent
							
								
									d9f8413402
								
							
						
					
					
						commit
						e43649fa62
					
				| 
						 | 
					@ -209,6 +209,7 @@ public:
 | 
				
			||||||
  /// getFunction - Look up the specified function in the module symbol table.
 | 
					  /// getFunction - Look up the specified function in the module symbol table.
 | 
				
			||||||
  /// If it does not exist, return null.
 | 
					  /// If it does not exist, return null.
 | 
				
			||||||
  Function *getFunction(const std::string &Name) const;
 | 
					  Function *getFunction(const std::string &Name) const;
 | 
				
			||||||
 | 
					  Function *getFunction(const char *Name) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// @}
 | 
					/// @}
 | 
				
			||||||
/// @name Global Variable Accessors
 | 
					/// @name Global Variable Accessors
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -67,6 +67,7 @@ public:
 | 
				
			||||||
  /// @returns the value associated with the \p name
 | 
					  /// @returns the value associated with the \p name
 | 
				
			||||||
  /// @brief Lookup a named Value.
 | 
					  /// @brief Lookup a named Value.
 | 
				
			||||||
  Value *lookup(const std::string &name) const;
 | 
					  Value *lookup(const std::string &name) const;
 | 
				
			||||||
 | 
					  Value *lookup(const char *NameBegin, const char *NameEnd) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// @returns true iff the symbol table is empty
 | 
					  /// @returns true iff the symbol table is empty
 | 
				
			||||||
  /// @brief Determine if the symbol table is empty
 | 
					  /// @brief Determine if the symbol table is empty
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -201,6 +201,11 @@ Function *Module::getFunction(const std::string &Name) const {
 | 
				
			||||||
  return dyn_cast_or_null<Function>(SymTab.lookup(Name));
 | 
					  return dyn_cast_or_null<Function>(SymTab.lookup(Name));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Function *Module::getFunction(const char *Name) const {
 | 
				
			||||||
 | 
					  const ValueSymbolTable &SymTab = getValueSymbolTable();
 | 
				
			||||||
 | 
					  return dyn_cast_or_null<Function>(SymTab.lookup(Name, Name+strlen(Name)));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//===----------------------------------------------------------------------===//
 | 
					//===----------------------------------------------------------------------===//
 | 
				
			||||||
// Methods for easy access to the global variables in the module.
 | 
					// Methods for easy access to the global variables in the module.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,6 +54,14 @@ Value *ValueSymbolTable::lookup(const std::string &Name) const {
 | 
				
			||||||
  return 0;
 | 
					  return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Value *ValueSymbolTable::lookup(const char *NameBegin,
 | 
				
			||||||
 | 
					                                const char *NameEnd) const {
 | 
				
			||||||
 | 
					  const_iterator VI = vmap.find(NameBegin, NameEnd);
 | 
				
			||||||
 | 
					  if (VI != vmap.end())                   // We found the symbol
 | 
				
			||||||
 | 
					    return VI->getValue();
 | 
				
			||||||
 | 
					  return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Insert a value into the symbol table with the specified name...
 | 
					// Insert a value into the symbol table with the specified name...
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
void ValueSymbolTable::reinsertValue(Value* V) {
 | 
					void ValueSymbolTable::reinsertValue(Value* V) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue