Skip to content

Commit fbd9d9f

Browse files
cleanup: inline slotmap_key_ffi helper for clarity
Remove the `slotmap_key_ffi` helper and inline `key.data().as_ffi()` at each call site. This makes the symmetry with the generated `KeyData::from_ffi(ffi).into()` more visible. Co-authored-by: Infinity 🤖 <infinity@hydro.run> PR: #2810
1 parent 62e78a6 commit fbd9d9f

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

dfir_lang/src/graph/meta_graph.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -822,12 +822,6 @@ impl DfirGraph {
822822
prefix: TokenStream,
823823
diagnostics: &mut Diagnostics,
824824
) -> Result<TokenStream, Diagnostics> {
825-
// Convert a slotmap key to its FFI representation for use in generated code.
826-
// The FFI value can reconstruct the key at runtime via `KeyData::from_ffi`.
827-
fn slotmap_key_ffi(key: impl Key) -> u64 {
828-
key.data().as_ffi()
829-
}
830-
831825
let df = Ident::new(GRAPH, Span::call_site());
832826
let context = Ident::new(CONTEXT, Span::call_site());
833827

@@ -972,7 +966,7 @@ impl DfirGraph {
972966
let mut subgraph_blocks = Vec::new();
973967
{
974968
for &(subgraph_id, subgraph_nodes) in all_subgraphs.iter() {
975-
let sg_metrics_ffi = slotmap_key_ffi(subgraph_id);
969+
let sg_metrics_ffi = subgraph_id.data().as_ffi();
976970
let (recv_hoffs, send_hoffs) = &subgraph_handoffs[subgraph_id];
977971

978972
// Generate buffer ident helpers for this subgraph's handoffs.
@@ -1009,7 +1003,7 @@ impl DfirGraph {
10091003
.zip(recv_buf_idents.iter())
10101004
.zip(recv_hoffs.iter())
10111005
.map(|((port_ident, buf_ident), &hoff_id)| {
1012-
let hoff_ffi = slotmap_key_ffi(hoff_id);
1006+
let hoff_ffi = hoff_id.data().as_ffi();
10131007
// Use call_site span for internal identifiers to avoid
10141008
// hygiene issues when invoked through declarative macros
10151009
// (e.g. dfir_expect_warnings!). TODO(#2781): define these once.
@@ -1434,7 +1428,7 @@ impl DfirGraph {
14341428
.iter()
14351429
.zip(send_buf_idents.iter())
14361430
.map(|(&hoff_id, buf_ident)| {
1437-
let hoff_ffi = slotmap_key_ffi(hoff_id);
1431+
let hoff_ffi = hoff_id.data().as_ffi();
14381432
quote! {
14391433
__dfir_metrics.handoffs[
14401434
#root::slotmap::KeyData::from_ffi(#hoff_ffi).into()
@@ -1483,7 +1477,7 @@ impl DfirGraph {
14831477
// Generate metrics initialization: one entry per handoff and per subgraph.
14841478
let metrics_init_code = {
14851479
let handoff_inits = handoff_nodes.iter().map(|&(node_id, _)| {
1486-
let ffi = slotmap_key_ffi(node_id);
1480+
let ffi = node_id.data().as_ffi();
14871481
quote! {
14881482
dfir_metrics.handoffs.insert(
14891483
#root::slotmap::KeyData::from_ffi(#ffi).into(),
@@ -1492,7 +1486,7 @@ impl DfirGraph {
14921486
}
14931487
});
14941488
let subgraph_inits = all_subgraphs.iter().map(|&(sg_id, _)| {
1495-
let ffi = slotmap_key_ffi(sg_id);
1489+
let ffi = sg_id.data().as_ffi();
14961490
quote! {
14971491
dfir_metrics.subgraphs.insert(
14981492
#root::slotmap::KeyData::from_ffi(#ffi).into(),

0 commit comments

Comments
 (0)