Skip to content

Commit eb63173

Browse files
authored
Use formatter precision to limit number of lines printed in the allocator breakdown (#133)
1 parent dbac563 commit eb63173

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/d3d12/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,11 @@ impl fmt::Debug for Allocator {
767767
fmt_bytes(total_size_in_bytes)
768768
)?;
769769

770-
for alloc in &allocation_report {
770+
let max_num_allocations_to_print = f.precision().map_or(usize::MAX, |n| n);
771+
for (idx, alloc) in allocation_report.iter().enumerate() {
772+
if idx >= max_num_allocations_to_print {
773+
break;
774+
}
771775
writeln!(
772776
f,
773777
"{:max_len$.max_len$}\t- {}",

src/vulkan/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,12 @@ impl fmt::Debug for Allocator {
477477
fmt_bytes(total_size_in_bytes)
478478
)?;
479479

480-
for alloc in &allocation_report {
480+
let max_num_allocations_to_print = f.precision().map_or(usize::MAX, |n| n);
481+
for (idx, alloc) in allocation_report.iter().enumerate() {
482+
if idx >= max_num_allocations_to_print {
483+
break;
484+
}
485+
481486
writeln!(
482487
f,
483488
"{:max_len$.max_len$}\t- {}",

0 commit comments

Comments
 (0)