Commit 41c7d55
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
1 file changed
+0
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | 47 | | |
51 | 48 | | |
52 | 49 | | |
| |||
0 commit comments