From 7188602d1fde203df0c657eb82db8cebcd8ff1f0 Mon Sep 17 00:00:00 2001 From: cxl Date: Fri, 29 Nov 2013 11:27:55 +0000 Subject: [PATCH] CtrlLib: TextCtrl::Load further optimized git-svn-id: svn://ultimatepp.org/upp/trunk@6616 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlLib/Text.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/uppsrc/CtrlLib/Text.cpp b/uppsrc/CtrlLib/Text.cpp index c18bb09c6..511a72a73 100644 --- a/uppsrc/CtrlLib/Text.cpp +++ b/uppsrc/CtrlLib/Text.cpp @@ -101,18 +101,30 @@ int TextCtrl::Load(Stream& s, byte charset) { charset = CHARSET_UTF8; } bool cr = false; + byte b8 = 0; while(!s.IsEof()) { int c = s.Get(); if(c == '\r') cr = true; if(c == '\n') { - WString w = ToUnicode(~ln, ln.GetCount(), charset); - line.Add(w); - total += w.GetLength() + 1; + if(b8 & 128) { // There are some chars > 127, need to convert + WString w = ToUnicode(~ln, ln.GetCount(), charset); + line.Add(w); + total += w.GetLength() + 1; + } + else { + total += ln.GetCount() + 1; + Ln& l = line.Add(); + l.len = ln.GetCount(); + l.text = ln; + } ln.Clear(); + b8 = 0; } - if(c >= ' ' || c == '\t') + if(c >= ' ' || c == '\t') { + b8 |= c; ln.Cat(c); + } } WString w = ToUnicode(~ln, ln.GetCount(), charset); line.Add(w);