On Fri, Apr 28, 2017 at 10:22:29AM -0600, Jeff Law wrote:
> So the initialization could be done once per translation unit rather than
> once per function -- assuming the target character set doesn't change within
> a translation unit.
>
> That seems like it ought to be easy.
>
> The table-lookup seems like a reasonable cost and I don't think we should
> litter the code with conditionals to conditionally lookup based on whether
> or not the charsets are the same.
One option would be to have the cache array initialized say to 0 for
all chars except for % (which can be taken from target_percent or how is
that called), and then query (and cache) chars you need (you don't need
anything until % is seen, then obviously you need to translate chars
following that until end of the format string is recognized, then again
skip until next % etc.
And/or enhance libcpp and the langhooks so that they will tell you when
the exec charset is identical to host (or at least the subset format strings
care about).
Jakub