repeat
pos = utf8.find(str,"\\",pos+1)
until not pos or utf8.sub(str,1,pos) ~= utf8.sub(str2,1,pos)
I have some doubt about efficiency of this code.
find in loop
pos value have to be translated to byte offset, and this get even worse with every iteration as we move further from beginning.
So question: is there some internal optimization for loop usage?
sub after find
It has to repeat exactly the same translation of pos, which already was done in find.
So question: how to rewrite above example in more efficient way?
Consider such example:
I have some doubt about efficiency of this code.
find
in looppos
value have to be translated to byte offset, and this get even worse with every iteration as we move further from beginning. So question: is there some internal optimization for loop usage?sub
afterfind
It has to repeat exactly the same translation ofpos
, which already was done infind
. So question: how to rewrite above example in more efficient way?