From 2704ec407202477b4a87403cd40aa3e751f12831 Mon Sep 17 00:00:00 2001 From: Herman Semenoff Date: Sat, 18 Apr 2026 13:52:00 +0300 Subject: [PATCH] panel: decrease build time using C/C++ incomplete types/forward declaration References: - https://www.gnu.org/software/c-intro-and-ref/manual/html_node/Incomplete-Types.html - https://stackoverflow.com/questions/73586567/how-does-forward-declaration-save-compile-time - https://www.reddit.com/r/cpp/comments/84ewn5/forward_declarations_to_reduce_compiletime/ - https://arne-mertz.de/2018/03/forward-declarations/ --- Panel.c | 8 +++++--- Panel.h | 17 ++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Panel.c b/Panel.c index f0c38af65..e066145dc 100644 --- a/Panel.c +++ b/Panel.c @@ -18,10 +18,12 @@ in the source distribution for its full text. #include #include "CRT.h" +#include "FunctionBar.h" #include "ListItem.h" #include "Macros.h" #include "ProvideCurses.h" #include "RichString.h" +#include "Vector.h" #include "XUtils.h" @@ -33,7 +35,7 @@ const PanelClass Panel_class = { .eventHandler = Panel_selectByTyping, }; -Panel* Panel_new(int x, int y, int w, int h, const ObjectClass* type, bool owner, FunctionBar* fuBar) { +Panel* Panel_new(int x, int y, int w, int h, const ObjectClass* type, bool owner, struct FunctionBar_* fuBar) { Panel* this; this = xMalloc(sizeof(Panel)); Object_setClass(this, Class(Panel)); @@ -47,7 +49,7 @@ void Panel_delete(Object* cast) { free(this); } -void Panel_init(Panel* this, int x, int y, int w, int h, const ObjectClass* type, bool owner, FunctionBar* fuBar) { +void Panel_init(Panel* this, int x, int y, int w, int h, const ObjectClass* type, bool owner, struct FunctionBar_* fuBar) { this->x = x; this->y = y; this->w = w; @@ -211,7 +213,7 @@ void Panel_setSelected(Panel* this, int selected) { } } -void Panel_splice(Panel* this, Vector* from) { +void Panel_splice(Panel* this, struct Vector_* from) { assert (this != NULL); assert (from != NULL); diff --git a/Panel.h b/Panel.h index e7620e08a..e565d8583 100644 --- a/Panel.h +++ b/Panel.h @@ -11,13 +11,12 @@ in the source distribution for its full text. #include #include "CRT.h" -#include "FunctionBar.h" #include "Object.h" #include "RichString.h" -#include "Vector.h" +struct FunctionBar_; +struct Vector_; -struct Panel_; typedef struct Panel_ Panel; typedef enum HandlerResult_ { @@ -64,7 +63,7 @@ struct Panel_ { Object super; int x, y, w, h; int cursorX, cursorY; - Vector* items; + struct Vector_* items; int selected; int oldSelected; size_t selectedLen; @@ -74,8 +73,8 @@ struct Panel_ { bool needsRedraw; bool cursorOn; bool wasFocus; - FunctionBar* currentBar; - FunctionBar* defaultBar; + struct FunctionBar_* currentBar; + struct FunctionBar_* defaultBar; RichString header; ColorElements selectionColorId; }; @@ -86,11 +85,11 @@ struct Panel_ { extern const PanelClass Panel_class; -Panel* Panel_new(int x, int y, int w, int h, const ObjectClass* type, bool owner, FunctionBar* fuBar); +Panel* Panel_new(int x, int y, int w, int h, const ObjectClass* type, bool owner, struct FunctionBar_* fuBar); void Panel_delete(Object* cast); -void Panel_init(Panel* this, int x, int y, int w, int h, const ObjectClass* type, bool owner, FunctionBar* fuBar); +void Panel_init(Panel* this, int x, int y, int w, int h, const ObjectClass* type, bool owner, struct FunctionBar_* fuBar); void Panel_done(Panel* this); @@ -130,7 +129,7 @@ void Panel_setSelected(Panel* this, int selected); void Panel_draw(Panel* this, bool force_redraw, bool focus, bool highlightSelected, bool hideFunctionBar); -void Panel_splice(Panel* this, Vector* from); +void Panel_splice(Panel* this, struct Vector_* from); bool Panel_onKey(Panel* this, int key);