From b42a5efb0ebdfeb8a8ea8d93377d4d564e32e154 Mon Sep 17 00:00:00 2001 From: cxl Date: Fri, 18 Jul 2014 12:18:44 +0000 Subject: [PATCH] Fixed issue in TextCtrl::Load optimization git-svn-id: svn://ultimatepp.org/upp/trunk@7521 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlLib/Text.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/uppsrc/CtrlLib/Text.cpp b/uppsrc/CtrlLib/Text.cpp index 752a3cd5d..11c44d36e 100644 --- a/uppsrc/CtrlLib/Text.cpp +++ b/uppsrc/CtrlLib/Text.cpp @@ -127,9 +127,11 @@ int TextCtrl::Load(Stream& in, byte charset) { { LTIMING("ChkLoop UTF8"); while(s < e && (*s >= ' ' || *s == '\t')) { - s++; - while(s < e && *s >= ' ') + b8 |= *s++; + while(s < e && *s >= ' ' && *s < 128) // Interestingly, this speeds things up s++; + while(s < e && *s >= ' ') + b8 |= *s++; } } if(b < s) { @@ -140,9 +142,10 @@ int TextCtrl::Load(Stream& in, byte charset) { cr = true; if(*s == '\n') { LTIMING("ADD"); - total += ln.GetCount() + 1; + int len = (b8 & 0x80) ? utf8len(~ln, ln.GetCount()) : ln.GetCount(); + total += len + 1; Ln& l = line.Add(); - l.len = ln.GetCount(); + l.len = len; l.text = ln; ln.Clear(); b8 = 0;