From 67c429e4b4bca052a5b17ec8c55b9236bf8c28c4 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Fri, 8 May 2015 18:08:18 +0300 Subject: [PATCH] Avoid unneeded printer object creation --- tinyxml2.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 6e1985b..3c0eef3 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -1928,11 +1928,13 @@ XMLError XMLDocument::Parse( const char* p, size_t len ) void XMLDocument::Print( XMLPrinter* streamer ) const { - XMLPrinter stdStreamer( stdout ); - if ( !streamer ) { - streamer = &stdStreamer; + if ( streamer ) { + Accept( streamer ); + } + else { + XMLPrinter stdoutStreamer( stdout ); + Accept( &stdoutStreamer ); } - Accept( streamer ); }