Thanks, that's definitely the source of the problem. I appreciate
the explanation. I did some more tests with this and found that
searches with bracket expressions in my UTF-8 locale are slow when
the elements inside the brackets contain both a single-byte character
and a multi-byte character. So [ab], [üçå], [美国], and [ł天] are all
fast, but [人a] and [aö] are quite slow.
Maybe I need to think more about how UTF-8 works, but I don't quite
see why these bracket expressions need to be as slow as they are.