Skip to content

Commit 7a5ad35

Browse files
committed
Pass a byte slice to coverageinfo::hash_bytes instead of an owned vector
The function body immediately treats it as a slice anyway, so this just makes it possible to call the hash function with arbitrary read-only byte slices.
1 parent 29c53d8 commit 7a5ad35

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub fn finalize(cx: &CodegenCx<'_, '_>) {
9595

9696
let filenames_size = filenames_buffer.len();
9797
let filenames_val = cx.const_bytes(&filenames_buffer);
98-
let filenames_ref = coverageinfo::hash_bytes(filenames_buffer);
98+
let filenames_ref = coverageinfo::hash_bytes(&filenames_buffer);
9999

100100
// Generate the LLVM IR representation of the coverage map and store it in a well-known global
101101
let cov_data_val = mapgen.generate_coverage_map(cx, version, filenames_size, filenames_val);

compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ pub(crate) fn hash_str(strval: &str) -> u64 {
378378
unsafe { llvm::LLVMRustCoverageHashCString(strval.as_ptr()) }
379379
}
380380

381-
pub(crate) fn hash_bytes(bytes: Vec<u8>) -> u64 {
381+
pub(crate) fn hash_bytes(bytes: &[u8]) -> u64 {
382382
unsafe { llvm::LLVMRustCoverageHashByteArray(bytes.as_ptr().cast(), bytes.len()) }
383383
}
384384

0 commit comments

Comments
 (0)