Avoid performance penalty on encoding when key-fn is not specified.