From 74c6662af5d9748baff7c32e8f0baf7996dd898e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 21 Aug 2019 16:31:26 +0900 Subject: Hoisted out rb_digest_namespace --- ext/digest/digest.h | 7 +++++++ ext/digest/md5/md5init.c | 4 +--- ext/digest/rmd160/rmd160init.c | 4 +--- ext/digest/sha1/sha1init.c | 4 +--- ext/digest/sha2/sha2init.c | 4 +--- 5 files changed, 11 insertions(+), 12 deletions(-) (limited to 'ext/digest') diff --git a/ext/digest/digest.h b/ext/digest/digest.h index 30359ad348..d9997b5db0 100644 --- a/ext/digest/digest.h +++ b/ext/digest/digest.h @@ -49,3 +49,10 @@ rb_digest_##name##_finish(void *ctx, unsigned char *ptr) \ { \ return name##_Final(ptr, ctx); \ } + +static inline VALUE +rb_digest_namespace(void) +{ + rb_require("digest"); + return rb_path2class("Digest"); +} diff --git a/ext/digest/md5/md5init.c b/ext/digest/md5/md5init.c index fdd8b36c5d..dafd38a29c 100644 --- a/ext/digest/md5/md5init.c +++ b/ext/digest/md5/md5init.c @@ -51,12 +51,10 @@ Init_md5(void) { VALUE mDigest, cDigest_Base, cDigest_MD5; - rb_require("digest"); - #if 0 mDigest = rb_define_module("Digest"); /* let rdoc know */ #endif - mDigest = rb_path2class("Digest"); + mDigest = rb_digest_namespace(); cDigest_Base = rb_path2class("Digest::Base"); cDigest_MD5 = rb_define_class_under(mDigest, "MD5", cDigest_Base); diff --git a/ext/digest/rmd160/rmd160init.c b/ext/digest/rmd160/rmd160init.c index 10d9370163..a2c0a023c0 100644 --- a/ext/digest/rmd160/rmd160init.c +++ b/ext/digest/rmd160/rmd160init.c @@ -49,12 +49,10 @@ Init_rmd160(void) { VALUE mDigest, cDigest_Base, cDigest_RMD160; - rb_require("digest"); - #if 0 mDigest = rb_define_module("Digest"); /* let rdoc know */ #endif - mDigest = rb_path2class("Digest"); + mDigest = rb_digest_namespace(); cDigest_Base = rb_path2class("Digest::Base"); cDigest_RMD160 = rb_define_class_under(mDigest, "RMD160", cDigest_Base); diff --git a/ext/digest/sha1/sha1init.c b/ext/digest/sha1/sha1init.c index e12d297699..3adf424b1d 100644 --- a/ext/digest/sha1/sha1init.c +++ b/ext/digest/sha1/sha1init.c @@ -53,12 +53,10 @@ Init_sha1(void) { VALUE mDigest, cDigest_Base, cDigest_SHA1; - rb_require("digest"); - #if 0 mDigest = rb_define_module("Digest"); /* let rdoc know */ #endif - mDigest = rb_path2class("Digest"); + mDigest = rb_digest_namespace(); cDigest_Base = rb_path2class("Digest::Base"); cDigest_SHA1 = rb_define_class_under(mDigest, "SHA1", cDigest_Base); diff --git a/ext/digest/sha2/sha2init.c b/ext/digest/sha2/sha2init.c index 9fd8ece7fe..99450bb29e 100644 --- a/ext/digest/sha2/sha2init.c +++ b/ext/digest/sha2/sha2init.c @@ -42,11 +42,9 @@ Init_sha2(void) FOREACH_BITLEN(DECLARE_ALGO_CLASS) - rb_require("digest"); - id_metadata = rb_intern_const("metadata"); - mDigest = rb_path2class("Digest"); + mDigest = rb_digest_namespace(); cDigest_Base = rb_path2class("Digest::Base"); #define DEFINE_ALGO_CLASS(bitlen) \ -- cgit v1.2.1