2) added string preallocation to the parser
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11854
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
wxStringTokenizer tokenizer(s, wxT(", "));
while (tokenizer.HasMoreTokens())
wxStringTokenizer tokenizer(s, wxT(", "));
while (tokenizer.HasMoreTokens())
- m_HandlersHash.Put(tokenizer.NextToken(), handler);
+ m_HandlersHash.Put(tokenizer.GetNextToken(), handler);
if (m_HandlersList.IndexOf(handler) == wxNOT_FOUND)
m_HandlersList.Append(handler);
if (m_HandlersList.IndexOf(handler) == wxNOT_FOUND)
m_HandlersList.Append(handler);
while (tokenizer.HasMoreTokens())
{
while (tokenizer.HasMoreTokens())
{
- key = tokenizer.NextToken();
+ key = tokenizer.GetNextToken();
m_HandlersHash.Delete(key);
m_HandlersHash.Put(key, handler);
}
m_HandlersHash.Delete(key);
m_HandlersHash.Put(key, handler);
}
const wxChar *c, *last;
const wxChar *in_str = input.c_str();
wxString output;
const wxChar *c, *last;
const wxChar *in_str = input.c_str();
wxString output;
+
+ output.reserve(input.length());
for (c = in_str, last = in_str; *c != wxT('\0'); c++)
{
for (c = in_str, last = in_str; *c != wxT('\0'); c++)
{
if (c - last > 0)
output.append(last, c - last);
if (++c == wxT('\0')) break;
if (c - last > 0)
output.append(last, c - last);
if (++c == wxT('\0')) break;
wxString entity;
const wxChar *ent_s = c;
wxString entity;
const wxChar *ent_s = c;
for (; (*c >= wxT('a') && *c <= wxT('z')) ||
(*c >= wxT('A') && *c <= wxT('Z')) ||
(*c >= wxT('0') && *c <= wxT('9')) ||
for (; (*c >= wxT('a') && *c <= wxT('z')) ||
(*c >= wxT('A') && *c <= wxT('Z')) ||
(*c >= wxT('0') && *c <= wxT('9')) ||
entity.append(ent_s, c - ent_s);
if (*c != wxT(';')) c--;
last = c+1;
entity.append(ent_s, c - ent_s);
if (*c != wxT(';')) c--;
last = c+1;
- output << GetEntityChar(entity);
+ entity_char = GetEntityChar(entity);
+ if (entity_char)
+ output << entity_char;
+ else
+ {
+ output.append(ent_s-1, c-ent_s+2);
+ wxLogDebug(wxT("Unrecognized HTML entity: '%s'"), entity.c_str());
+ }
}
}
if (*last != wxT('\0'))
}
}
if (*last != wxT('\0'))
else
return GetCharForCode(code);
}
else
return GetCharForCode(code);
}