From d12262068d689eacc452a459a021df0ad8f6d46c Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 27 Mar 2019 14:56:10 -0300 Subject: 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. --- testes/utf8.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'testes') 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) 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" -- cgit v1.2.3-55-g6feb