From 2a89d8021cf95f4a4d7dab269a262a1d2237f71b Mon Sep 17 00:00:00 2001 From: Ginger Bill Date: Thu, 8 Jun 2017 12:54:52 +0100 Subject: Use templated `Array` with bounds checking --- src/timings.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/timings.cpp') diff --git a/src/timings.cpp b/src/timings.cpp index 046f476fe..04c1667f4 100644 --- a/src/timings.cpp +++ b/src/timings.cpp @@ -6,7 +6,7 @@ typedef struct TimeStamp { typedef struct Timings { TimeStamp total; - Array(TimeStamp) sections; + Array sections; u64 freq; } Timings; @@ -83,7 +83,7 @@ TimeStamp make_time_stamp(String label) { } void timings_init(Timings *t, String label, isize buffer_size) { - array_init_reserve(&t->sections, heap_allocator(), buffer_size); + array_init(&t->sections, heap_allocator(), buffer_size); t->total = make_time_stamp(label); t->freq = time_stamp__freq(); } @@ -94,7 +94,7 @@ void timings_destroy(Timings *t) { void timings__stop_current_section(Timings *t) { if (t->sections.count > 0) { - t->sections.e[t->sections.count-1].finish = time_stamp_time_now(); + t->sections[t->sections.count-1].finish = time_stamp_time_now(); } } @@ -117,7 +117,7 @@ void timings_print_all(Timings *t) { max_len = t->total.label.len; for_array(i, t->sections) { - TimeStamp ts = t->sections.e[i]; + TimeStamp ts = t->sections[i]; max_len = gb_max(max_len, ts.label.len); } @@ -129,7 +129,7 @@ void timings_print_all(Timings *t) { time_stamp_as_ms(t->total, t->freq)); for_array(i, t->sections) { - TimeStamp ts = t->sections.e[i]; + TimeStamp ts = t->sections[i]; gb_printf("%.*s%.*s - %.3f ms\n", LIT(ts.label), cast(int)(max_len-ts.label.len), SPACES, -- cgit v1.2.3