From 77c0e075907a0dc97712c10ed63442da4168bd0c Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Wed, 10 Aug 2016 16:33:40 -0300 Subject: [PATCH] aeeshow/sch.h, sch-parse.c: record subsheets in parent, for future caching --- eeshow/sch-parse.c | 11 +++++++++-- eeshow/sch.h | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/eeshow/sch-parse.c b/eeshow/sch-parse.c index 0101351..2959f50 100644 --- a/eeshow/sch-parse.c +++ b/eeshow/sch-parse.c @@ -288,6 +288,10 @@ static struct sheet *new_sheet(struct sch_ctx *ctx) sheet->next_obj = &sheet->objs; sheet->next = NULL; + sheet->children = NULL; + sheet->next_child = &sheet->children; + sheet->next_sib = NULL; + sheet->parent = ctx->curr_sheet; ctx->curr_sheet = sheet; @@ -312,7 +316,7 @@ static const struct sheet *recurse_sheet(struct sch_ctx *ctx, const struct file *related) { const char *name = ctx->obj.u.sheet.file; - const struct sheet *sheet; + struct sheet *sheet; struct file file; bool res; @@ -326,6 +330,10 @@ static const struct sheet *recurse_sheet(struct sch_ctx *ctx, return NULL; /* caller MUST clean up */ end_sheet(ctx); + *ctx->curr_sheet->next_child = sheet; + ctx->curr_sheet->next_child = &sheet->next_sib; + sheet->next_sib = NULL; + return sheet; } @@ -640,4 +648,3 @@ void sch_free(struct sch_ctx *ctx) ctx->sheets = next; } } - diff --git a/eeshow/sch.h b/eeshow/sch.h index 1aa31c7..4bb08f9 100644 --- a/eeshow/sch.h +++ b/eeshow/sch.h @@ -98,6 +98,10 @@ struct sheet { struct sch_obj **next_obj; struct sheet *parent; struct sheet *next; + + struct sheet *children; /* "child" sub-sheets */ + struct sheet **next_child; + struct sheet *next_sib; /* siblings sub-sheets of this sheet */ }; struct sch_ctx {