A thing I want to stress, is that you pay for the "complexity" just once, and it gets amortized over all projects that use this code.
This is a standard technique, that is often used in String functions. You can see it also in implementations of strlen.