From 65dd46e0bba74948c824370a06e509cba462cd72 Mon Sep 17 00:00:00 2001 From: Randy Palamar Date: Mon, 1 Dec 2025 22:08:13 -0700 Subject: main: make vis instance into a global This might be controversial to some but for the purposes of the editor there will never be more than one instance of vis. This allows the compiler to use more efficient rip relative addressing in the places where it knows the code is referring to the global instance. Once the code is compiling in a single translation unit with all functions declared static this will allow for much better optimization. From the perspective that vis is meant to be a library, which is what Marc clearly intended, changing vis_new() to vis_init() and vis_free() to vis_cleanup() is still better design. The library user should be allowed to place the vis instance wherever they want in memory. --- vis.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'vis.h') diff --git a/vis.h b/vis.h index 2b5ce52..8e367ed 100644 --- a/vis.h +++ b/vis.h @@ -99,10 +99,13 @@ typedef struct { * @defgroup vis_lifecycle Vis Lifecycle * @{ */ -/** Create a new editor instance. */ -Vis *vis_new(void); -/** Free all resources associated with this editor instance, terminates UI. */ -void vis_free(Vis*); +/** + * Initializes a new editor instance. + * @param vis The editor instance. + */ +bool vis_init(Vis*); +/** Release all resources associated with this editor instance, terminates UI. */ +void vis_cleanup(Vis*); /** * Enter main loop, start processing user input. * @param vis The editor instance. -- cgit v1.2.3