]> git.neil.brown.name Git - edlib.git/commitdiff
Introduce ->root pointer in panes.
authorNeilBrown <neil@brown.name>
Mon, 12 Jun 2023 00:47:27 +0000 (10:47 +1000)
committerNeilBrown <neil@brown.name>
Wed, 28 Jun 2023 07:51:41 +0000 (17:51 +1000)
pane->root gets straight to the root, so we can efficiently access
global state.

Signed-off-by: NeilBrown <neil@brown.name>
core-pane.c
core.h

index d5a5410b75927755770a82f324f4bb07ad64c552..3f91238f5a3e114794fc584bfbcdc96354ae4714 100644 (file)
@@ -42,9 +42,11 @@ static void pane_init(struct pane *p safe, struct pane *par)
        if (par) {
                p->parent = par;
                list_add(&p->siblings, &par->children);
+               p->root = par->root;
        } else {
                p->parent = p;
                INIT_LIST_HEAD(&p->siblings);
+               p->root = p;
        }
        INIT_LIST_HEAD(&p->children);
        INIT_LIST_HEAD(&p->notifiers);
diff --git a/core.h b/core.h
index 3631c374bf04ed2bcdcea06b3d63aae6d5086539..5ce003934dc3749ae444403c7dea7deeef436964 100644 (file)
--- a/core.h
+++ b/core.h
@@ -83,6 +83,7 @@ struct pane {
         */
        unsigned int            timestamp;
 
+       struct pane             *root;
        struct command          *handle;
        void                    *data safe;
        struct attrset          *attrs;
@@ -499,9 +500,7 @@ struct pane *__doc_register(struct pane *parent safe,
 
 static inline struct pane * safe pane_root(struct pane *p safe)
 {
-       while (p->parent != p)
-               p = p->parent;
-       return p;
+       return p->root;
 }
 
 static inline struct pane *safe pane_leaf(struct pane *p safe)