[lld] 3ade3d3 - [lld/mac] Replace while loop with for loop
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 21 12:45:16 PDT 2022
Author: Nico Weber
Date: 2022-06-21T15:42:06-04:00
New Revision: 3ade3d372408a49d6f18106f4ad0b19fd6dfacdc
URL: https://github.com/llvm/llvm-project/commit/3ade3d372408a49d6f18106f4ad0b19fd6dfacdc
DIFF: https://github.com/llvm/llvm-project/commit/3ade3d372408a49d6f18106f4ad0b19fd6dfacdc.diff
LOG: [lld/mac] Replace while loop with for loop
No behavior change. In preparation for using a parallelFor() here.
Differential Revision: https://reviews.llvm.org/D128295
Added:
Modified:
lld/MachO/SyntheticSections.cpp
Removed:
################################################################################
diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index 1aa8a4d86185..7c8957618b1e 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -1253,14 +1253,11 @@ uint64_t CodeSignatureSection::getRawSize() const {
void CodeSignatureSection::writeHashes(uint8_t *buf) const {
// NOTE: Changes to this functionality should be repeated in llvm-objcopy's
// MachOWriter::writeSignatureData.
- uint8_t *code = buf;
- uint8_t *codeEnd = buf + fileOff;
- uint8_t *hashes = codeEnd + allHeadersSize;
- while (code < codeEnd) {
- sha256(code, std::min(static_cast<size_t>(codeEnd - code), blockSize),
- hashes);
- code += blockSize;
- hashes += hashSize;
+ uint8_t *hashes = buf + fileOff + allHeadersSize;
+ for (uint64_t i = 0; i < getBlockCount(); ++i) {
+ sha256(buf + i * blockSize,
+ std::min(static_cast<size_t>(fileOff - i * blockSize), blockSize),
+ hashes + i * hashSize);
}
#if defined(__APPLE__)
// This is macOS-specific work-around and makes no sense for any
More information about the llvm-commits
mailing list