1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Let the index boundary check in rb_enc_from_index be flagged as unlikely

[Misc #15806]

Closes: https://github.com/ruby/ruby/pull/2128
This commit is contained in:
Lourens Naudé 2019-04-13 17:39:05 +01:00 committed by Nobuyoshi Nakada
parent 6546aed475
commit 009ec37a47
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -608,7 +608,7 @@ rb_enc_init(void)
rb_encoding *
rb_enc_from_index(int index)
{
if (index < 0 || enc_table.count <= (index &= ENC_INDEX_MASK)) {
if (UNLIKELY(index < 0 || enc_table.count <= (index &= ENC_INDEX_MASK))) {
return 0;
}
return enc_table.list[index].enc;