Skip to content

Commit 61d3b0d

Browse files
committed
[ClangImporter] Avoid unneeded copy for getExportedModuleName
std::string -> StringRef of long-lived backing storage. No functionality change.
1 parent bfc2753 commit 61d3b0d

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

include/swift/ClangImporter/ClangModule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ClangModuleUnit final : public LoadedFile {
6262
/// Retrieve the "exported" name of the module, which is usually the module
6363
/// name, but might be the name of the public module through which this
6464
/// (private) module is re-exported.
65-
std::string getExportedModuleName() const;
65+
StringRef getExportedModuleName() const;
6666

6767
virtual bool isSystemModule() const override;
6868

lib/ClangImporter/ClangImporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3146,7 +3146,7 @@ clang::ASTContext &ClangModuleUnit::getClangASTContext() const {
31463146
return owner.getClangASTContext();
31473147
}
31483148

3149-
std::string ClangModuleUnit::getExportedModuleName() const {
3149+
StringRef ClangModuleUnit::getExportedModuleName() const {
31503150
if (clangModule && !clangModule->ExportAsModule.empty())
31513151
return clangModule->ExportAsModule;
31523152

lib/Serialization/Deserialization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ static bool isReExportedToModule(const ValueDecl *value,
11491149
= dyn_cast<ClangModuleUnit>(valueDC->getModuleScopeContext());
11501150
if (!fromClangModule)
11511151
return false;
1152-
std::string exportedName = fromClangModule->getExportedModuleName();
1152+
StringRef exportedName = fromClangModule->getExportedModuleName();
11531153

11541154
auto toClangModule
11551155
= dyn_cast<ClangModuleUnit>(expectedModule->getFiles().front());

lib/Serialization/ModuleFile.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,11 +1847,9 @@ void ModuleFile::loadExtensions(NominalTypeDecl *nominal) {
18471847

18481848
// If the originating module is a private module whose interface is
18491849
// re-exported via public module, check the name of the public module.
1850-
std::string exportedModuleName;
18511850
if (auto clangModuleUnit =
18521851
dyn_cast<ClangModuleUnit>(parentModule->getFiles().front())) {
1853-
exportedModuleName = clangModuleUnit->getExportedModuleName();
1854-
moduleName = exportedModuleName;
1852+
moduleName = clangModuleUnit->getExportedModuleName();
18551853
}
18561854

18571855
for (auto item : *iter) {

0 commit comments

Comments
 (0)