From e45af4aead1edde2e557e9437119f17bc982c7e9 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 20 Feb 2012 23:12:00 +0000 Subject: Trim some fat by taking advantage of ReadContext for statement emission. git-svn-id: http://svn.drobilla.net/serd/trunk@310 490d8e77-9747-427b-9fa3-0b8f29cee8a0 --- src/reader.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/reader.c b/src/reader.c index 71c00b4d..85799a00 100644 --- a/src/reader.c +++ b/src/reader.c @@ -233,16 +233,14 @@ pop_node(SerdReader* reader, Ref ref) } static inline bool -emit_statement(SerdReader* reader, SerdStatementFlags* flags, - Ref g, Ref s, Ref p, Ref o, - Ref d, Ref l) +emit_statement(SerdReader* reader, ReadContext ctx, Ref o, Ref d, Ref l) { bool ret = !reader->statement_sink || !reader->statement_sink( - reader->handle, *flags, - deref(reader, g), deref(reader, s), deref(reader, p), + reader->handle, *ctx.flags, deref(reader, ctx.graph), + deref(reader, ctx.subject), deref(reader, ctx.predicate), deref(reader, o), deref(reader, d), deref(reader, l)); - *flags &= SERD_ANON_CONT|SERD_LIST_CONT; // Preserve only cont flags + *ctx.flags &= SERD_ANON_CONT|SERD_LIST_CONT; // Preserve only cont flags return ret; } @@ -1002,9 +1000,7 @@ read_blank(SerdReader* reader, ReadContext ctx, bool subject, Ref* dest) *dest = blank_id(reader); if (ctx.subject) { - TRY_RET(emit_statement(reader, ctx.flags, - ctx.graph, ctx.subject, ctx.predicate, - *dest, 0, 0)); + TRY_RET(emit_statement(reader, ctx, *dest, 0, 0)); } ctx.subject = *dest; @@ -1091,9 +1087,7 @@ read_object(SerdReader* reader, ReadContext ctx) if (ret && emit) { deref(reader, o)->flags = flags; - ret = emit_statement(reader, ctx.flags, - ctx.graph, ctx.subject, ctx.predicate, - o, datatype, lang); + ret = emit_statement(reader, ctx, o, datatype, lang); } except: @@ -1165,8 +1159,7 @@ read_collection(SerdReader* reader, ReadContext ctx, Ref* dest) if (ctx.subject) { // subject predicate _:head *ctx.flags |= (end ? 0 : SERD_LIST_O_BEGIN); - TRY_RET(emit_statement(reader, ctx.flags, ctx.graph, - ctx.subject, ctx.predicate, *dest, 0, 0)); + TRY_RET(emit_statement(reader, ctx, *dest, 0, 0)); *ctx.flags |= SERD_LIST_CONT; } else { *ctx.flags |= (end ? 0 : SERD_LIST_S_BEGIN); @@ -1204,8 +1197,8 @@ read_collection(SerdReader* reader, ReadContext ctx, Ref* dest) // _:node rdf:rest _:rest *ctx.flags |= SERD_LIST_CONT; - TRY_RET(emit_statement(reader, ctx.flags, ctx.graph, - ctx.subject, reader->rdf_rest, + ctx.predicate = reader->rdf_rest; + TRY_RET(emit_statement(reader, ctx, (end ? reader->rdf_nil : rest), 0, 0)); ctx.subject = rest; // _:node = _:rest -- cgit v1.2.1