I remember submitting a patch to Scintilla so it at least uses binary search to check whether the word is in the keyword list but Neil wanted to have this optimized for smaller number of keywords where the linear search won so the patch wasn't accepted.
It's https://sourceforge.net/p/scintilla/feature-requests/1312/, here is the implementation for Notepad2 https://github.com/zufuliu/notepad2/blob/main/scintilla/lexlib/WordList.cxx#...