Skip to content

Commit 41c7d55

Browse files
authored
d2: remove unreachable early return in legend rendering (#118)
## Summary Follow up from a review comment on PR #111. Removes an unreachable early return in D2 legend rendering. ## Problem In `src/mk_graph/output/d2.rs`: ``` let legend_lines = ctx.allocs_legend_lines(); if legend_lines.is_empty() { return; } ``` As pointed out by @dkcumming, `allocs_legend_lines()` always inserts the `"ALLOCS"` header, so this condition can never be true. ## Change Remove the dead branch and rely on the invariant guaranteed by `allocs_legend_lines()`. ## Diff ```diff fn render_d2_allocs_legend(ctx: &GraphContext, out: &mut String) { let legend_lines = ctx.allocs_legend_lines(); - if legend_lines.is_empty() { - return; - } out.push_str("ALLOCS: {\n"); out.push_str(" style.fill: \"#ffffcc\"\n"); ``` ## Review context #111 (comment)
1 parent a5b714d commit 41c7d55

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

src/mk_graph/output/d2.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ impl SmirJson<'_> {
4444

4545
fn render_d2_allocs_legend(ctx: &GraphContext, out: &mut String) {
4646
let legend_lines = ctx.allocs_legend_lines();
47-
if legend_lines.is_empty() {
48-
return;
49-
}
5047

5148
out.push_str("ALLOCS: {\n");
5249
out.push_str(" style.fill: \"#ffffcc\"\n");

0 commit comments

Comments
 (0)