You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm uncertain about this commit.
There are three separate DFA tables already in core. One accepts Perl
extended UTF-8; one accepts only strict Unicode UTF-8; and the third
accepts modified Unicode UTF-8 spelled out by them in Corrigendum Perl#9.
Both the Unicode varieties reject surrogate code points and anything
above U+10FFFF. C9 accepts, but the other rejects non-character code
points.
Without this commit, the way it works is it uses the most restrictive
table for the DFA. Anything it accepts is always valid. Anything it
rejects is potentially problematic, and it calls a non-inlined function
to examine the input more slowly to determine if it is acceptable and/or
if a warning needs to be raised.
This commit examines the input flags to determine which DFA to use
in this situation. The benefit is that the slower routine could be
avoided for many more code points.
But the vast vast majority of calls to this function aren't for any
problematic code points, so the extra cost of this will very rarely be
recouped. The translation from UTF-8 is critically important. We want
it to be as fast as possible. I would not even consider this commit if
the extra cost weren't very small.
A complicating factor is that 2048 (approximately 20% of the total)
Korean Hangul syllable code points are not handled by the strict table,
so must be by the slower function; though they're handled at the very
beginning of it. These code points are never problematic, so it is
unfortunate that they have to be handled via the slower function. But
still, rarely will this function be called with them. Only the strict
table has this problem
The way this commit works is to have a table containing pointers to the
three DFA tables. The function looks at the input flags; if none are
present, it uses the loosest dfa; if any restrictions are present, it
adds 1 to the index to use, and it the C9 resetrictions are present, it
adds an extra 1. The flags are cast to bools to get each addition. If
the bool casts didn't generate conditionals, the only cost to this would
be two additions and an indirection; and I would say that that cost is
so tiny that this would be worth it. But I looked at godbolt, and
casting to bool requires a comparison on both modern clang and gcc.
That makes me unsure of the tradeoff.
Another option would be to just juse two DFAs, loose and most strict.
Then there would be a single conditional, and the Hanguls still would be
handled by the DFA when there were no flags restricting things
0 commit comments