Hi Andrew, Thanks for working on this. I tried two further optimizations on top of v4. They can be applied independently:
1. unicode_assigned() still calls pg_mbstrlen_with_len() on the remaining input, then walks it again to check each code point. 0001 uses the byte length to walk to the end directly. This also avoids scanning the whole suffix before returning false for an unassigned code point near the beginning. 2. unicode_normalize_func() and unicode_is_normalized() allocate a C string for the normalization form on every call, even when the input is all ASCII. 0002 compares the form directly in the text value, preserving case-insensitive matching and rejecting extra bytes. It only builds a C string when reporting an invalid form. 0003 replaces the constant-folded VALUES test with stored short and compressed text values. Core regression and the Unicode normalization checks passed with these patches. Regards, Rui
nocfbot-0001-Avoid-counting-code-points-before-checking-Unicode-a.patch
Description: Binary data
nocfbot-0002-Avoid-allocating-a-C-string-for-the-normalization-fo.patch
Description: Binary data
nocfbot-0003-Exercise-ASCII-normalization-with-stored-text-values.patch
Description: Binary data
