Most of the work for detecting non-normalized NFC is lookup of codepoints in a fairly small table. For the case of identifiers, it looks like some additional optimization may be possible, as many characters are already excluded.
Adding
Detection of un-normalized text is fairly straight-forward, and GCC 10 already produces a warning. Unicode Annex 15, Unicode Normalization Forms, provides a quick check algorithm to test if a a string is in one of the normalization forms, driven by tables in the unicode database. See [Detecting_Normalization_Forms](
https://unicode.org/reports/tr15/#Detecting_Normalization_Forms) in [@UAX15]. The tables are available at [DerivedNormalizationProps.txt](
http://www.unicode.org/Public/UCD/latest/ucd/DerivedNormalizationProps.txt). The check algorithm will sometimes need to normalize short ranges of text where detection of YES or NO is not possible for the single codepoint.