clore::extract::ensure_cache_key_impl
Owner: Module extract:compiler
Declaration: extract/compiler.cppm:119
Definition: extract/compiler.cppm:119
Declaration: Namespace clore::extract
Implementation
cpp
auto ensure_cache_key_impl(CompileEntry& entry) -> void {
entry.normalized_file = normalize_entry_file(entry);
entry.compile_signature = build_compile_signature_impl(entry, entry.normalized_file);
entry.source_hash = try_hash_source_file(entry.normalized_file);
entry.cache_key =
clore::support::build_cache_key(entry.normalized_file, entry.compile_signature);
}ensure_cache_key_impl 通过依次填充 CompileEntry 的四个关键字段来构造缓存键。它首先调用 normalize_entry_file 将条目的源文件路径规范化,结果写入 entry.normalized_file。然后调用 build_compile_signature_impl 基于该规范化路径生成编译签名,存入 entry.compile_signature。接着用 try_hash_source_file 尝试哈希源文件,结果存入 entry.source_hash;该调用可能返回空,但函数在此处不检查其结果——缓存键的最终构建依赖 clore::support::build_cache_key,它仅使用规范化路径和编译签名组成 entry.cache_key。
整个流程是线性的,无分支或错误处理;它假定所有被调用的辅助函数均能成功完成,并将结果直接赋值给传入的 CompileEntry。该函数是 ensure_cache_key 的内部实现,将缓存键的构造分解为独立的子步骤,便于测试和复用。
Side Effects
- Modifies the fields of the passed
CompileEntry& - Reads the source file for hashing via
try_hash_source_file
Reads From
- The
CompileEntryparameterentry - The file system via
normalize_entry_fileandtry_hash_source_file
Writes To
entry.normalized_fileentry.compile_signatureentry.source_hashentry.cache_key
Usage Patterns
- Called by
clore::extract::ensure_cache_key
Calls
- function
clore::extract::(anonymous namespace)::build_compile_signature_impl - function
clore::extract::(anonymous namespace)::try_hash_source_file - function
clore::extract::normalize_entry_file
Called By
- function
clore::extract::ensure_cache_key