Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. jit.opt.start("hotloop=1")
  2.  
  3. local iteration = 0
  4. local function test(value)
  5. iteration = iteration + 1
  6. --print("a") -- printing fixes wrong behavior
  7. local pos_c = string.find(value, "c", 1, true)
  8. --assert(pos_c == 3, "pos=" .. pos_c)
  9. --pos_c = 3 -- use of constant fixes wrong behavior
  10. local value2 = string.sub(value, 1, pos_c - 1)
  11. local pos_b = string.find(value2, "b", 2, true)
  12. assert(pos_b == 2, "dot1=" .. pos_b)
  13. end
  14.  
  15. local function test_loop()
  16. for _ = 1, 20 do
  17. test("abc")
  18. end
  19. end
  20.  
  21. test("abc")
  22.  
  23. local _, err = pcall(test_loop)
  24. print(iteration)
  25. print(err or "ok")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement