From d45efbe6400b7620dea34c1c9e80443396b480a1 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 17 Aug 2018 15:24:52 +0200 Subject: [PATCH] Don't reload source file, if it's already there. --- server/TracyView.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index db36e479..391c43dd 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -405,16 +405,19 @@ void View::InitTextEditor() void View::SetTextEditorFile( const char* fileName, int line ) { - FILE* f = fopen( fileName, "rb" ); - fseek( f, 0, SEEK_END ); - const auto sz = ftell( f ); - fseek( f, 0, SEEK_SET ); - std::string data; - data.resize( sz ); - fread( data.data(), 1, sz, f ); - fclose( f ); + if( !m_textEditorFile || strcmp( m_textEditorFile, fileName ) != 0 ) + { + FILE* f = fopen( fileName, "rb" ); + fseek( f, 0, SEEK_END ); + const auto sz = ftell( f ); + fseek( f, 0, SEEK_SET ); + std::string data; + data.resize( sz ); + fread( data.data(), 1, sz, f ); + fclose( f ); + m_textEditor->SetText( data ); + } - m_textEditor->SetText( data ); m_textEditor->SetCursorPosition( TextEditor::Coordinates( line-1, 0 ) ); m_textEditorFile = fileName;