lua-users home
lua-l archive

Re: Bug in pattern matching

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


> I believe I've found a bug in the pattern matching implementation.
> Executing the code below shows that each iteration takes under 1
> second.
> 
> local pattern = "b"
> for len=10000,100000,10000 do
> local t = os.time()
> ("a"):rep(len):find(pattern)
> print(len, os.time() - t)
> end
> 
> On the other hand, if the pattern string is ".*b", this is how long
> it's taking:
> 
> [...]
This is literally a textbook example: http://www.lua.org/pil/20.4.html
> [...] I think some "cleverness" is missing in the implementation.
Missing cleverness is not a bug.
-- Roberto

AltStyle によって変換されたページ (->オリジナル) /