ruby-changes:53243
From: ko1 <ko1@a...>
Date: Wed, 31 Oct 2018 07:55:36 +0900 (JST)
Subject: [ruby-changes:53243] ko1:r65458 (trunk): fix type.
ko1 2018-10-31 07:55:31 +0900 (Wed, 31 Oct 2018) New Revision: 65458 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65458 Log: fix type. * internal.h (RHASH_ARRAY_SIZE_RAW): should be `int` because it returns n<=8. * hash.c (RHASH_ARRAY_BOUND_RAW): ditto. * hash.c (RHASH_ARRAY_SIZE_RAW): remove a duplicated definition. * hash.c (linear_keys, linear_values): return `long`. * hash.c (linear_keys): fix initialize expression of `key_end`. Modified files: trunk/hash.c trunk/internal.h Index: hash.c =================================================================== --- hash.c (revision 65457) +++ hash.c (revision 65458) @@ -347,15 +347,12 @@ empty_entry(li_table_entry *entry) https://github.com/ruby/ruby/blob/trunk/hash.c#L347 return entry->hash == 0; } -#define RHASH_ARRAY_SIZE_RAW(h) \ - ((long)((RBASIC(h)->flags & RHASH_ARRAY_SIZE_MASK) >> RHASH_ARRAY_SIZE_SHIFT)) - #define RHASH_ARRAY_SIZE(h) (HASH_ASSERT(RHASH_ARRAY_P(h)), \ RHASH_ARRAY_SIZE_RAW(h)) #define RHASH_ARRAY_BOUND_RAW(h) \ - ((long)((RBASIC(h)->flags >> RHASH_ARRAY_BOUND_SHIFT) & \ - (RHASH_ARRAY_BOUND_MASK >> RHASH_ARRAY_BOUND_SHIFT))) + ((int)((RBASIC(h)->flags >> RHASH_ARRAY_BOUND_SHIFT) & \ + (RHASH_ARRAY_BOUND_MASK >> RHASH_ARRAY_BOUND_SHIFT))) #define RHASH_ARRAY_BOUND(h) (HASH_ASSERT(RHASH_ARRAY_P(h)), \ RHASH_ARRAY_BOUND_RAW(h)) @@ -949,11 +946,11 @@ linear_shift(VALUE hash, st_data_t *key, https://github.com/ruby/ruby/blob/trunk/hash.c#L946 return 0; } -static int +static long linear_keys(VALUE hash, st_data_t *keys, st_index_t size) { uint8_t i, bound = RHASH_ARRAY_BOUND(hash); - st_data_t *keys_start = keys, *keys_end = keys_end; + st_data_t *keys_start = keys, *keys_end = keys + size; for (i = 0; i < bound; i++) { if (keys == keys_end) { @@ -969,7 +966,7 @@ linear_keys(VALUE hash, st_data_t *keys, https://github.com/ruby/ruby/blob/trunk/hash.c#L966 return keys - keys_start; } -static int +static long linear_values(VALUE hash, st_data_t *values, st_index_t size) { uint8_t i, bound = RHASH_ARRAY_BOUND(hash); Index: internal.h =================================================================== --- internal.h (revision 65457) +++ internal.h (revision 65458) @@ -686,7 +686,7 @@ enum ruby_rhash_flags { https://github.com/ruby/ruby/blob/trunk/internal.h#L686 #define HASH_PROC_DEFAULT FL_USER2 #define RHASH_ARRAY_SIZE_RAW(h) \ - ((long)((RBASIC(h)->flags & RHASH_ARRAY_SIZE_MASK) >> RHASH_ARRAY_SIZE_SHIFT)) + ((int)((RBASIC(h)->flags & RHASH_ARRAY_SIZE_MASK) >> RHASH_ARRAY_SIZE_SHIFT)) int rb_hash_array_p(VALUE hash); struct li_table *rb_hash_array(VALUE hash); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/