improve replace performance (only one loop)
No creation of buffer if no param or {} not found