From 0e739f34801ff6810064a8fac570f6be2b61ae70 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 13 Aug 2021 20:31:57 -0400 Subject: Simplify output stream API This makes the paging mechanism an internal detail once again. While it's conceptually elegant to simply have a single write interface and have the block dumper just be another implementation of that, unfortunately it is not practical. The inlining of serd_block_dumper_write() is a significant performance boost, because it avoids a non-inlinable function call of overhead per character. Compared to the SerdByteSink approach, this removes the burden and overhead of needing to dynamically allocate the structure itself. --- src/node_syntax.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/node_syntax.c') diff --git a/src/node_syntax.c b/src/node_syntax.c index 1dadc7b8..d2768c3e 100644 --- a/src/node_syntax.c +++ b/src/node_syntax.c @@ -98,22 +98,22 @@ serd_node_to_syntax_in(const SerdNode* const node, const SerdSyntax syntax, const SerdEnv* const env) { - SerdWorld* const world = serd_world_new(); - SerdBuffer buffer = {NULL, 0}; - SerdByteSink* const out = serd_byte_sink_new_buffer(&buffer); - SerdWriter* const writer = serd_writer_new(world, syntax, 0, env, out); + SerdWorld* const world = serd_world_new(); + SerdBuffer buffer = {NULL, 0}; + SerdOutputStream out = serd_open_output_buffer(&buffer); + SerdWriter* const writer = serd_writer_new(world, syntax, 0, env, &out, 1); char* result = NULL; if (!serd_writer_write_node(writer, node) && !serd_writer_finish(writer) && - !serd_byte_sink_close(out)) { + !serd_close_output(&out)) { result = (char*)buffer.buf; } else { - serd_byte_sink_close(out); + serd_close_output(&out); free(buffer.buf); } serd_writer_free(writer); - serd_byte_sink_free(out); + serd_close_output(&out); serd_world_free(world); return result; -- cgit v1.2.1