From 870d64c46eda8d8519386502c03b35bca587e253 Mon Sep 17 00:00:00 2001 From: kohait Date: Wed, 3 Oct 2012 21:34:27 +0000 Subject: [PATCH] bazaar: LogCtrl is buffered now for performance reasons and threading git-svn-id: svn://ultimatepp.org/upp/trunk@5406 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- bazaar/LogCtrl/LogCtrl.cpp | 29 ++++++++++++++++------------- bazaar/LogCtrl/LogCtrl.h | 4 ++-- bazaar/LogCtrl/init | 1 - 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/bazaar/LogCtrl/LogCtrl.cpp b/bazaar/LogCtrl/LogCtrl.cpp index 2e9aeb4dc..0accdb317 100644 --- a/bazaar/LogCtrl/LogCtrl.cpp +++ b/bazaar/LogCtrl/LogCtrl.cpp @@ -5,7 +5,9 @@ LoggerCtrl::LoggerCtrl() : maxlines(1000), ignore(false) NoInitFocus(); NoWantFocus(); SetReadOnly(); - //Reserve(maxlines*64); + Reserve(512); + + SetTimeCallback(-200, THISBACK(Flush)); } void LoggerCtrl::Save() @@ -32,23 +34,24 @@ void LoggerCtrl::Updated() void LoggerCtrl::_Put(int w) { if(ignore) return; - String d; - d.Cat(w); - //String s = EscapeCh((unsigned)w); - GuiLock _; - Insert(GetLength(), d); - SetCursor(GetLength()); + StringStream::_Put(w); } void LoggerCtrl::_Put(const void *data, dword size) { if(ignore) return; - String d; - d.Cat((const char*)data, size); - //String s = EscapeCh(d); - GuiLock _; - Insert(GetLength(), d); - SetCursor(GetLength()); + StringStream::_Put(data, size); +} + +void LoggerCtrl::Flush() +{ + if(StringStream::GetSize() > 0) + { + Insert(GetLength(), GetResult()); + SetCursor(GetLength()); + StringStream::Create(); //empty + Reserve(512); + } } LogCtrl::LogCtrl() : ps(NULL) diff --git a/bazaar/LogCtrl/LogCtrl.h b/bazaar/LogCtrl/LogCtrl.h index 223436892..4f8fdc359 100644 --- a/bazaar/LogCtrl/LogCtrl.h +++ b/bazaar/LogCtrl/LogCtrl.h @@ -44,7 +44,7 @@ inline void LogLev(int l) { Single() = (LOGLEV)l;} /// -class LoggerCtrl : public DocEdit, public Stream +class LoggerCtrl : public DocEdit, public StringStream { public: typedef LoggerCtrl CLASSNAME; @@ -58,7 +58,7 @@ public: int GetMaxLines() const { return maxlines; } virtual void Updated(); - virtual bool IsOpen() const { return true; } + virtual void Flush(); protected: virtual void _Put(int w); diff --git a/bazaar/LogCtrl/init b/bazaar/LogCtrl/init index 82514a5e4..59b0aaf01 100644 --- a/bazaar/LogCtrl/init +++ b/bazaar/LogCtrl/init @@ -1,5 +1,4 @@ #ifndef _LogCtrl_icpp_init_stub #define _LogCtrl_icpp_init_stub #include "CtrlLib/init" -#include "EscapeCh/init" #endif