fix major encoding perf bug