From 9524447bf12272b7e79ffcd600cd3f6a69aab44b Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Wed, 10 Aug 2016 19:41:17 -0300 Subject: [PATCH] eeshow/sch.h (struct sheet.parent): remove; we can just record it locally --- eeshow/delta.c | 1 - eeshow/sch-parse.c | 17 +++++------------ eeshow/sch.h | 1 - 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/eeshow/delta.c b/eeshow/delta.c index bb6be43..74c1e1d 100644 --- a/eeshow/delta.c +++ b/eeshow/delta.c @@ -278,7 +278,6 @@ static void init_res(struct sheet *res) res->title = NULL; res->objs = NULL; res->next_obj = &res->objs; - res->parent = NULL; res->next = NULL; } diff --git a/eeshow/sch-parse.c b/eeshow/sch-parse.c index 0ce5c85..922f9f9 100644 --- a/eeshow/sch-parse.c +++ b/eeshow/sch-parse.c @@ -292,7 +292,6 @@ static struct sheet *new_sheet(struct sch_ctx *ctx) sheet->oid = NULL; - sheet->parent = ctx->curr_sheet; ctx->curr_sheet = sheet; *ctx->next_sheet = sheet; @@ -302,13 +301,6 @@ static struct sheet *new_sheet(struct sch_ctx *ctx) } -static void end_sheet(struct sch_ctx *ctx) -{ - ctx->curr_sheet = ctx->curr_sheet->parent; - assert(ctx->curr_sheet); -} - - static bool parse_line(const struct file *file, void *user, const char *line); @@ -317,7 +309,7 @@ static const struct sheet *recurse_sheet(struct sch_ctx *ctx, const struct file *related) { const char *name = ctx->obj.u.sheet.file; - struct sheet *sheet; + struct sheet *parent, *sheet; struct file file; void *oid; bool res; @@ -325,6 +317,7 @@ static const struct sheet *recurse_sheet(struct sch_ctx *ctx, if (!file_open(&file, name, related)) return NULL; + parent = ctx->curr_sheet; sheet = new_sheet(ctx); oid = file_oid(&file); sheet->oid = oid; @@ -335,7 +328,7 @@ static const struct sheet *recurse_sheet(struct sch_ctx *ctx, for (other = ctx->prev->sheets; other; other = other->next) if (!other->has_children && file_oid_eq(other->oid, oid)) { - end_sheet(ctx); + ctx->curr_sheet = parent; sheet->title = other->title; sheet->objs = other->objs; return sheet; @@ -347,9 +340,9 @@ static const struct sheet *recurse_sheet(struct sch_ctx *ctx, file_close(&file); if (!res) return NULL; /* leave it to caller to clean up */ - end_sheet(ctx); - ctx->curr_sheet->has_children = 1; + ctx->curr_sheet = parent; + parent->has_children = 1; return sheet; } diff --git a/eeshow/sch.h b/eeshow/sch.h index 4d2e534..8b7c94c 100644 --- a/eeshow/sch.h +++ b/eeshow/sch.h @@ -96,7 +96,6 @@ struct sheet { const char *title; /* malloced, unless delta */ struct sch_obj *objs; struct sch_obj **next_obj; - struct sheet *parent; struct sheet *next; bool has_children; /* aka sub-sheets */