this repo has no description

condense sample deinit

altagos.dev bc3dd573 79132158

verified
+11 -31
+11 -31
src/austin.zig
··· 35 35 process: Process, 36 36 frames: []FrameWrapper, 37 37 metric: Metric, 38 - 39 - fn deinit(self: *Sample, allocator: mem.Allocator) void { 40 - for (self.frames) |frame| { 41 - switch (frame) { 42 - .invalid => {}, 43 - .call_stack => |stack| { 44 - allocator.free(stack.module); 45 - allocator.free(stack.function); 46 - }, 47 - } 48 - } 49 - 50 - allocator.free(self.frames); 51 - } 52 38 }; 53 39 54 40 pub const PartialSample = struct { 55 41 process: Process, 56 42 frames: []FrameWrapper, 57 - 58 - fn deinit(self: *PartialSample, allocator: mem.Allocator) void { 59 - for (self.frames) |frame| { 60 - switch (frame) { 61 - .invalid => {}, 62 - .call_stack => |stack| { 63 - allocator.free(stack.module); 64 - allocator.free(stack.function); 65 - }, 66 - } 67 - } 68 - 69 - allocator.free(self.frames); 70 - } 71 43 }; 72 44 73 45 pub const SampleWrapper = union(enum) { ··· 78 50 fn deinit(self: *SampleWrapper, allocator: mem.Allocator) void { 79 51 switch (self.*) { 80 52 .metric => {}, 81 - .full => |*sample| { 82 - sample.deinit(allocator); 53 + inline else => |*sample| { 54 + for (sample.frames) |frame| { 55 + switch (frame) { 56 + .invalid => {}, 57 + .call_stack => |stack| { 58 + allocator.free(stack.module); 59 + allocator.free(stack.function); 60 + }, 61 + } 62 + } 63 + allocator.free(sample.frames); 83 64 }, 84 - .partial => |*sample| sample.deinit(allocator), 85 65 } 86 66 } 87 67 };