Re: Qi + UTF-32 (Unicode) question regarding performance (small example attached)
"Mathias Born" <[email protected]>
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I found out by following the flow in a debugger,
and so I answer the question myself.
In the end, all parsing is done by comparing characters.
For example, the literal parser (in home/qi/detail/string_parse.hpp)
does:
for (; !!ch; ++i)
{
if (i == last || (ch != *i))
return false;
ch = *++str;
}
where (in the example I posted) the type of ch is "char" and the type
of *i is "char32_t". This means there is no unnecessary conversion
and there should be no performance problem at all.
The same applies to numerical parsers.
In order to use 32-bit literals, one would probably have to write
corresponding trait-specializations following the contents of
home/support/string_traits.hpp, but I didn't try that.
Hope this helps anyone,
Best Regards,
Mathias
> -----Original Message-----
> From: Mathias Born [mailto:[email protected]]
> Sent: Montag, 23. Januar 2017 22:06
> To: [email protected]
> Subject: [Spirit-general] Qi + UTF-32 (Unicode) question regarding
> performance (small example attached)
>
> Hi,
>
> I'd appreciate advice on how to achieve best performance. I need to parse
> text encoded as UTF-32.
> A minimal example is attached and looks like this:
> ...
> However, I wonder what happens behind the scenes. Parsers "test1" and
> "test2" use literals which are not UTF-32.
> (At least on Windows, where wchar_t is 16 bit.)
> But the input is, so isn't there a conversion to UTF-32 necessary at
> runtime? If so, I'd like to use UTF-32 literals
> in order to avoid any conversion, but that doesn't compile (see "test3").
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot