mirror of
https://github.com/lua/lua
synced 2026-09-29 04:35:58 +03:00
Small optimizations in range checks
Checks of the form '1 <= x && x <= M' were rewritten in the form '(unsigned)x - 1 < (unsigned)M', which is usually more efficient. (Other similar checks have similar translations.) Although some compilers do these optimizations, that does not happen for all compilers or all cases.
This commit is contained in:
parent
0443ad9e28
commit
d12262068d
4 changed files with 20 additions and 11 deletions
|
|
@ -123,6 +123,9 @@ checkerror("continuation byte", utf8.offset, "𦧺", 1, 2)
|
|||
checkerror("continuation byte", utf8.offset, "𦧺", 1, 2)
|
||||
checkerror("continuation byte", utf8.offset, "\x80", 1)
|
||||
|
||||
-- error in indices for len
|
||||
checkerror("out of string", utf8.len, "abc", 0, 2)
|
||||
checkerror("out of string", utf8.len, "abc", 1, 4)
|
||||
|
||||
|
||||
local s = "hello World"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue