Yes that's a truly horrid function implementation indeed!
That fact that a const is missing on key is the least of its problems.
The only redeeming quality I could find is that the indentation is correct.