|
If I remember correctly, the first thing gsub does is checking if the second argument is a pattern or not and, if not, it goes on with a direct replace. Thus the performance impact is minimal in that case -a linear scan over the second arg string.
This if I understood the question correctly, if not, sorry :)
The Lua API string.gsub will also take a pattern as an argument. I am assuming that because of the assumption that a pattern may be present as an argument, there will be additional processing that will be done every time a string comparison is made. If we know for sure that the argument is going to be a string, is there way to avoid this additional performance penalty. I was looking for an API that operates only on string like strcpy in C , but could not find anythingIs there any faster way to do string substitution in Lua apart from using string.gsub.