Skip to content

Commit 53de2d8

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 d4565f3 commit 53de2d8

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

@@ -940,7 +934,7 @@ impl DfirGraph {
940934
let mut subgraph_blocks = Vec::new();
941935
{
942936
for &(subgraph_id, subgraph_nodes) in all_subgraphs.iter() {
943-
let sg_metrics_ffi = slotmap_key_ffi(subgraph_id);
937+
let sg_metrics_ffi = subgraph_id.data().as_ffi();
944938
let (recv_hoffs, send_hoffs) = &subgraph_handoffs[subgraph_id];
945939

946940
// Generate buffer ident helpers for this subgraph's handoffs.
@@ -976,7 +970,7 @@ impl DfirGraph {
976970
.zip(recv_buf_idents.iter())
977971
.zip(recv_hoffs.iter())
978972
.map(|((port_ident, buf_ident), &hoff_id)| {
979-
let hoff_ffi = slotmap_key_ffi(hoff_id);
973+
let hoff_ffi = hoff_id.data().as_ffi();
980974
// Use call_site span for internal identifiers to avoid
981975
// hygiene issues when invoked through declarative macros
982976
// (e.g. dfir_expect_warnings!). TODO(#2781): define these once.
@@ -1395,7 +1389,7 @@ impl DfirGraph {
13951389
.iter()
13961390
.zip(send_buf_idents.iter())
13971391
.map(|(&hoff_id, buf_ident)| {
1398-
let hoff_ffi = slotmap_key_ffi(hoff_id);
1392+
let hoff_ffi = hoff_id.data().as_ffi();
13991393
quote! {
14001394
__dfir_metrics.handoffs[
14011395
#root::slotmap::KeyData::from_ffi(#hoff_ffi).into()
@@ -1444,7 +1438,7 @@ impl DfirGraph {
14441438
// Generate metrics initialization: one entry per handoff and per subgraph.
14451439
let metrics_init_code = {
14461440
let handoff_inits = handoff_nodes.iter().map(|&(node_id, _)| {
1447-
let ffi = slotmap_key_ffi(node_id);
1441+
let ffi = node_id.data().as_ffi();
14481442
quote! {
14491443
dfir_metrics.handoffs.insert(
14501444
#root::slotmap::KeyData::from_ffi(#ffi).into(),
@@ -1453,7 +1447,7 @@ impl DfirGraph {
14531447
}
14541448
});
14551449
let subgraph_inits = all_subgraphs.iter().map(|&(sg_id, _)| {
1456-
let ffi = slotmap_key_ffi(sg_id);
1450+
let ffi = sg_id.data().as_ffi();
14571451
quote! {
14581452
dfir_metrics.subgraphs.insert(
14591453
#root::slotmap::KeyData::from_ffi(#ffi).into(),

0 commit comments

Comments
 (0)