optimize decode using a array storing last found index of char c