lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Thanks Marco. That was the query. Thanks for your prompt answer.


On Monday, 3 November 2014 2:02 PM, Marco Mastropaolo <marco@mastropaolo.com> wrote:


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 :)
Il 03/nov/2014 06:09 "Rv Rv" <rvrv7575@yahoo.com> ha scritto:
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 anything
Is there any faster way to do string substitution in Lua apart from using string.gsub.