refactor(evidence_capsule): Phase B language-advantage pass — dichotomy wave (allocation-free size sum)
This commit is contained in:
1 parent
db06ee4664
commit
7885e057ee
1 file changed
+10
-3
@@ -81,9 +81,16 @@ pub fn pack(claims: &[Json], contradictions: &[Json], limits: &[Json], raw_ref:
|
||||
}
|
||||
|
||||
pub fn size(capsule: &Json) -> i64 {
|
||||
as_list(capsule.get("claims")).len() as i64
|
||||
+ as_list(capsule.get("contradictions")).len() as i64
|
||||
+ as_list(capsule.get("limits")).len() as i64
|
||||
// Phase B (language advantage): one pass over the three slot keys —
|
||||
// the iterator sum never materializes the three intermediate Vec
|
||||
// clones the naive port would build.
|
||||
["claims", "contradictions", "limits"]
|
||||
.iter()
|
||||
.map(|k| match capsule.get(k) {
|
||||
Some(Json::Arr(xs)) => xs.len() as i64,
|
||||
_ => 0,
|
||||
})
|
||||
.sum()
|
||||
}
|
||||
|
||||
pub fn unpack(capsule: &Json) -> Json {
|
||||
|
||||
Reference in new issue
Block a user