in focus/internals/src/lib/model/outlining.rs [195:224]
fn write_to_file(&self, path: &Path) -> Result<Vec<u8>> {
static ENDLINE: &[u8] = b"\n";
let mut written_productions = HashSet::<OsString>::new();
let mut buf = Vec::<u8>::new();
let mut digest = Sha256::new();
for pattern in self.iter() {
let lines: Vec<OsString> = pattern.clone().into();
for line in lines {
if line.as_bytes().eq(MAIN_SEPARATOR_BYTES) {
// Skip root patterns (lines that are just "/")
continue;
}
if !written_productions.insert(line.clone()) {
// Skip previously written pattern
continue;
}
buf.extend(line.as_bytes());
buf.extend(ENDLINE);
}
}
digest.update(&buf);
std::fs::write(path, buf)
.with_context(|| format!("Writing the sparse profile to {}", path.display()))?;
let hash = digest.finalize().to_vec();
Ok(hash)
}