跳转至

ev-mold-array-digest-003

字段 值
项目 rui314/mold
固定 commit 27162691b71a
路径 src/icf.cc
行段 L79-L81
特性 std::array
许可证 MIT
代码来源 项目源码
级别 manual
审核 zyuhao7 @ 2026-11-03
测试代码 否
发现方式 manual

用法

用 std::array 定义固定长度的哈希摘要类型,并为其特化 std::hash

为什么典型

摘要长度是算法常量,std::array 让长度成为类型的一部分,可直接按值比较、复制并作为 unordered 容器键。

摘录

static constexpr int64_t HASH_SIZE = 16;

using Digest = std::array<uint8_t, HASH_SIZE>;

备注

生产路径;同一文件的 hash 特化直接遍历 array,说明固定长度缓冲区用 std::array 比 C 数组更易组合。

查看固定 commit 源码 · 返回证据索引