This is fundamentally quadratic code until #140907 is implemented. However, the old approach that didn't use `StringRef` was a few percent faster because it didn't have to call `strlen` as often. So this brings back a little bit of performance in cases like #140706. Pull Request: https://projects.blender.org/blender/blender/pulls/144012