CtrlLib: TextCtrl::Load further optimized

git-svn-id: svn://ultimatepp.org/upp/trunk@6616 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2013-11-29 11:27:55 +00:00
parent ca57f97f91
commit 7188602d1f

View file

@ -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);