Simplify rb_str_resize clear range condition

This commit is contained in:
tompng 2024-01-19 00:27:10 +09:00 committed by Jean Boussier
parent 04467218ce
commit a9b8981aac

View File

@ -3239,8 +3239,7 @@ rb_str_resize(VALUE str, long len)
long slen = RSTRING_LEN(str); long slen = RSTRING_LEN(str);
const int termlen = TERM_LEN(str); const int termlen = TERM_LEN(str);
if ((slen > len && ENC_CODERANGE(str) != ENC_CODERANGE_7BIT) || if (slen > len || (termlen != 1 && slen < len)) {
(termlen > 1 && (slen % termlen == 0) != (len % termlen == 0))) {
ENC_CODERANGE_CLEAR(str); ENC_CODERANGE_CLEAR(str);
} }