# HG changeset patch # User Raphaël Gomès # Date 1727690929 -7200 # Node ID 0ea323b7e3b163566c71da00c9ba93e8eab40bf2 # Parent d7bc6e4820339d0ad424f31c20aa9431b7bf0e96 rust-manifest: encode flags as `Option` This makes the compiler use the niche optimization for all flags: since 0 is not a valid representation of any flags, we can use 0 as a replacement for `None`, which reduces memory footprint and could yield a little performance improvement over many iterations. diff -r d7bc6e482033 -r 0ea323b7e3b1 rust/hg-core/src/revlog/manifest.rs --- a/rust/hg-core/src/revlog/manifest.rs Mon Sep 30 17:46:52 2024 +0200 +++ b/rust/hg-core/src/revlog/manifest.rs Mon Sep 30 12:08:49 2024 +0200 @@ -1,3 +1,5 @@ +use std::num::NonZeroU8; + use crate::errors::HgError; use crate::revlog::{Node, NodePrefix}; use crate::revlog::{Revlog, RevlogError}; @@ -178,7 +180,7 @@ pub hex_node_id: &'manifest [u8], /// `Some` values are b'x', b'l', or 't' - pub flags: Option, + pub flags: Option, } impl<'a> ManifestEntry<'a> { @@ -198,7 +200,7 @@ Self { path: HgPath::new(path), hex_node_id, - flags, + flags: flags.map(|f| f.try_into().expect("invalid flag")), } } diff -r d7bc6e482033 -r 0ea323b7e3b1 rust/rhg/src/commands/status.rs --- a/rust/rhg/src/commands/status.rs Mon Sep 30 17:46:52 2024 +0200 +++ b/rust/rhg/src/commands/status.rs Mon Sep 30 12:08:49 2024 +0200 @@ -776,13 +776,13 @@ let entry_flags = if check_exec { entry.flags - } else if entry.flags == Some(b'x') { + } else if entry.flags.map(|f| f.into()) == Some(b'x') { None } else { entry.flags }; - if entry_flags != fs_flags { + if entry_flags.map(|f| f.into()) != fs_flags { return Ok(UnsureOutcome::Modified); } let filelog = hg::filelog::Filelog::open_vfs(