Переглянути джерело

Remove IsPackage (#6497)

The work being done by `IsPackage` is more than is needed by callers.
Jon Ross-Perkins 4 місяців тому
батько
коміт
3ae6f96141

+ 2 - 2
toolchain/sem_ir/inst_fingerprinter.cpp

@@ -200,8 +200,8 @@ struct Worklist {
     }
     const auto& scope = sem_ir->name_scopes().Get(name_scope_id);
     Add(scope.name_id());
-    if (!sem_ir->name_scopes().IsPackage(name_scope_id) &&
-        scope.parent_scope_id().has_value()) {
+    // For non-package scopes, add the parent scope.
+    if (!scope.is_imported_package() && scope.parent_scope_id().has_value()) {
       Add(sem_ir->name_scopes().Get(scope.parent_scope_id()).inst_id());
     }
   }

+ 0 - 7
toolchain/sem_ir/name_scope.cpp

@@ -99,11 +99,4 @@ auto NameScopeStore::GetInstIfValid(NameScopeId scope_id) const
   return {inst_id, file_->insts().Get(inst_id)};
 }
 
-auto NameScopeStore::IsCorePackage(NameScopeId scope_id) const -> bool {
-  if (!IsPackage(scope_id)) {
-    return false;
-  }
-  return Get(scope_id).name_id() == NameId::Core;
-}
-
 }  // namespace Carbon::SemIR

+ 3 - 11
toolchain/sem_ir/name_scope.h

@@ -342,18 +342,10 @@ class NameScopeStore {
   auto GetInstIfValid(NameScopeId scope_id) const
       -> std::pair<InstId, std::optional<Inst>>;
 
-  // Returns whether the provided scope ID is for a package scope.
-  auto IsPackage(NameScopeId scope_id) const -> bool {
-    if (!scope_id.has_value()) {
-      return false;
-    }
-    // A package is either the current package or an imported package.
-    return scope_id == NameScopeId::Package ||
-           Get(scope_id).is_imported_package();
-  }
-
   // Returns whether the provided scope ID is for the Core package.
-  auto IsCorePackage(NameScopeId scope_id) const -> bool;
+  auto IsCorePackage(NameScopeId scope_id) const -> bool {
+    return scope_id.has_value() && Get(scope_id).name_id() == NameId::Core;
+  }
 
   // Returns whether the provided scope ID is valid and is directly contained
   // within the Core package.