From 34e4261210e9dbe6bdb0fdfc45ef46e769e55c07 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Fri, 27 Oct 2023 06:56:31 +0200 Subject: [PATCH] gtk: refactor the Paned deinit method --- src/apprt/gtk/Paned.zig | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/apprt/gtk/Paned.zig b/src/apprt/gtk/Paned.zig index 455158fdc..e94a494fc 100644 --- a/src/apprt/gtk/Paned.zig +++ b/src/apprt/gtk/Paned.zig @@ -220,19 +220,13 @@ fn surfaceInPosition(self: *Paned, position: Position) ?*Surface { } pub fn deinit(self: *Paned, alloc: Allocator) void { - switch (self.child1) { - .none, .surface => {}, - .paned => |paned| { - paned.deinit(alloc); - alloc.destroy(paned); - }, - } - - switch (self.child2) { - .none, .surface => {}, - .paned => |paned| { - paned.deinit(alloc); - alloc.destroy(paned); - }, + for ([_]Child{ self.child1, self.child2 }) |child| { + switch (child) { + .none, .surface => continue, + .paned => |paned| { + paned.deinit(alloc); + alloc.destroy(paned); + }, + } } }