diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-03-27 14:56:10 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-03-27 14:56:10 -0300 |
commit | d12262068d689eacc452a459a021df0ad8f6d46c (patch) | |
tree | d3e839cd1ddf3daf5e12c8f472c10a980b7d9d8c /testes | |
parent | 0443ad9e288825b6e4441eb11104bcdb4ff4593a (diff) | |
download | lua-d12262068d689eacc452a459a021df0ad8f6d46c.tar.gz lua-d12262068d689eacc452a459a021df0ad8f6d46c.tar.bz2 lua-d12262068d689eacc452a459a021df0ad8f6d46c.zip |
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.
Diffstat (limited to 'testes')
-rw-r--r-- | testes/utf8.lua | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/testes/utf8.lua b/testes/utf8.lua index 86ec1b00..b3b7687f 100644 --- a/testes/utf8.lua +++ b/testes/utf8.lua | |||
@@ -123,6 +123,9 @@ checkerror("continuation byte", utf8.offset, "𦧺", 1, 2) | |||
123 | checkerror("continuation byte", utf8.offset, "𦧺", 1, 2) | 123 | checkerror("continuation byte", utf8.offset, "𦧺", 1, 2) |
124 | checkerror("continuation byte", utf8.offset, "\x80", 1) | 124 | checkerror("continuation byte", utf8.offset, "\x80", 1) |
125 | 125 | ||
126 | -- error in indices for len | ||
127 | checkerror("out of string", utf8.len, "abc", 0, 2) | ||
128 | checkerror("out of string", utf8.len, "abc", 1, 4) | ||
126 | 129 | ||
127 | 130 | ||
128 | local s = "hello World" | 131 | local s = "hello World" |