lua-users home
lua-l archive

[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:

10000	0
20000	4
30000	7
40000	13
50000	19
60000	28
70000	39
80000	55
90000	67
100000	84

Not even ".*b$" helps. I think some "cleverness" is missing in the implementation.

Cheers
-- gabriel