perf: only do expensive conversions in debug mode