mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
save a few allocations in from_ascii.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25281 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c2d1b2ea82
commit
6a56be232d
@ -31,9 +31,12 @@ namespace lyx {
|
|||||||
docstring const from_ascii(char const * ascii)
|
docstring const from_ascii(char const * ascii)
|
||||||
{
|
{
|
||||||
docstring s;
|
docstring s;
|
||||||
for (char const * c = ascii; *c; ++c) {
|
int n = strlen(ascii);
|
||||||
LASSERT(static_cast<unsigned char>(*c) < 0x80, /**/);
|
s.resize(n);
|
||||||
s.push_back(*c);
|
char_type *d = &s[0];
|
||||||
|
while (--n >= 0) {
|
||||||
|
d[n] = ascii[n];
|
||||||
|
LASSERT(static_cast<unsigned char>(ascii[n]) < 0x80, /**/);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -99,8 +102,7 @@ docstring const from_utf8(string const & utf8)
|
|||||||
|
|
||||||
string const to_utf8(docstring const & ucs4)
|
string const to_utf8(docstring const & ucs4)
|
||||||
{
|
{
|
||||||
vector<char> const utf8 =
|
vector<char> const utf8 = ucs4_to_utf8(ucs4.data(), ucs4.size());
|
||||||
ucs4_to_utf8(ucs4.data(), ucs4.size());
|
|
||||||
return string(utf8.begin(), utf8.end());
|
return string(utf8.begin(), utf8.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user