Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jit.opt.start("hotloop=1")
- local iteration = 0
- local function test(value)
- iteration = iteration + 1
- --print("a") -- printing fixes wrong behavior
- local pos_c = string.find(value, "c", 1, true)
- --assert(pos_c == 3, "pos=" .. pos_c)
- --pos_c = 3 -- use of constant fixes wrong behavior
- local value2 = string.sub(value, 1, pos_c - 1)
- local pos_b = string.find(value2, "b", 2, true)
- assert(pos_b == 2, "dot1=" .. pos_b)
- end
- local function test_loop()
- for _ = 1, 20 do
- test("abc")
- end
- end
- test("abc")
- local _, err = pcall(test_loop)
- print(iteration)
- print(err or "ok")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement