How expensive is this method? I wonder what the tradeoff is in complexity vs. runtime performance.