Skip to content

[Serialization] Use StringRef::substr (NFC) #139678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

kazutakahirata
Copy link
Contributor

StringRef::substr is shorter here because we can rely on its default
second parameter.

StringRef::substr is shorter here because we can rely on its default
second parameter.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:modules C++20 modules and Clang Header Modules labels May 13, 2025
@llvmbot
Copy link
Member

llvmbot commented May 13, 2025

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-modules

Author: Kazu Hirata (kazutakahirata)

Changes

StringRef::substr is shorter here because we can rely on its default
second parameter.


Full diff: https://github.com/llvm/llvm-project/pull/139678.diff

1 Files Affected:

  • (modified) clang/lib/Serialization/ASTWriter.cpp (+1-1)
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index c4c0603839c62..7de510c85bfed 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1237,7 +1237,7 @@ ASTWriter::createSignature() const {
   Hasher.update(
       AllBytes.slice(UnhashedControlBlockRange.second, ASTBlockRange.first));
   //  3. After the AST block.
-  Hasher.update(AllBytes.slice(ASTBlockRange.second, StringRef::npos));
+  Hasher.update(AllBytes.substr(ASTBlockRange.second));
   ASTFileSignature Signature = ASTFileSignature::create(Hasher.result());
 
   return std::make_pair(ASTBlockHash, Signature);

@kazutakahirata kazutakahirata merged commit 69ce681 into llvm:main May 13, 2025
14 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_range_StringRef_slice_clang branch May 13, 2025 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:modules C++20 modules and Clang Header Modules clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants