Make the lookup up of type id accepts const arg

This commit is contained in:
qining 2016-08-11 18:19:50 -04:00
parent 82405cf499
commit f949e321f2
2 changed files with 3 additions and 3 deletions

View File

@ -40,7 +40,7 @@ Type* TypeManager::GetType(uint32_t id) const {
return nullptr;
}
uint32_t TypeManager::GetId(Type* type) const {
uint32_t TypeManager::GetId(const Type* type) const {
auto iter = type_to_id_.find(type);
if (iter != type_to_id_.end()) return (*iter).second;
return 0;

View File

@ -42,7 +42,7 @@ namespace analysis {
class TypeManager {
public:
using IdToTypeMap = std::unordered_map<uint32_t, std::unique_ptr<Type>>;
using TypeToIdMap = std::unordered_map<Type*, uint32_t>;
using TypeToIdMap = std::unordered_map<const Type*, uint32_t>;
using ForwardPointerVector = std::vector<std::unique_ptr<ForwardPointer>>;
TypeManager(const spvtools::ir::Module& module) { AnalyzeTypes(module); }
@ -56,7 +56,7 @@ class TypeManager {
Type* GetType(uint32_t id) const;
// Returns the id for the given |type|. Returns 0 if can not find the given
// |type|.
uint32_t GetId(Type* type) const;
uint32_t GetId(const Type* type) const;
// Returns the number of types hold in this manager.
size_t NumTypes() const { return id_to_type_.size(); }