summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-08-17 11:54:12 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-08-19 15:10:53 +0900
commit8cc5f74ffc4097173ae69b0098524a5faecaee7e (patch)
tree7564ff70cb6060b6a35eb9bce1a69c99a173d66d /internal
parent99093e1600ccef17ab99356b689573fcfd336ecc (diff)
RHASH_EMPTY_P: convert into an inline function
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3426
Diffstat (limited to 'internal')
-rw-r--r--internal/hash.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/internal/hash.h b/internal/hash.h
index 73d71deaa2..b0c23c2b2e 100644
--- a/internal/hash.h
+++ b/internal/hash.h
@@ -64,6 +64,10 @@ struct RHash {
# undef RHASH_SIZE
#endif
+#ifdef RHASH_EMPTY_P
+# undef RHASH_EMPTY_P
+#endif
+
/* hash.c */
void rb_hash_st_table_set(VALUE hash, st_table *st);
VALUE rb_hash_default_value(VALUE hash, VALUE key);
@@ -82,6 +86,7 @@ int rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func *fu
static inline unsigned RHASH_AR_TABLE_SIZE_RAW(VALUE h);
static inline VALUE RHASH_IFNONE(VALUE h);
static inline size_t RHASH_SIZE(VALUE h);
+static inline bool RHASH_EMPTY_P(VALUE h);
static inline bool RHASH_AR_TABLE_P(VALUE h);
static inline bool RHASH_ST_TABLE_P(VALUE h);
static inline struct ar_table_struct *RHASH_AR_TABLE(VALUE h);
@@ -174,6 +179,12 @@ RHASH_SIZE(VALUE h)
}
static inline bool
+RHASH_EMPTY_P(VALUE h)
+{
+ return RHASH_SIZE(h) == 0;
+}
+
+static inline bool
RHASH_ST_TABLE_P(VALUE h)
{
return ! RHASH_AR_TABLE_P(h);