ruby-changes:57207
From: Nobuyoshi <ko1@a...>
Date: Thu, 22 Aug 2019 00:20:27 +0900 (JST)
Subject: [ruby-changes:57207] Nobuyoshi Nakada: 74c6662af5 (master): Hoisted out rb_digest_namespace
https://git.ruby-lang.org/ruby.git/commit/?id=74c6662af5 From 74c6662af5d9748baff7c32e8f0baf7996dd898e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Wed, 21 Aug 2019 16:31:26 +0900 Subject: Hoisted out rb_digest_namespace diff --git a/ext/digest/digest.h b/ext/digest/digest.h index 30359ad..d9997b5 100644 --- a/ext/digest/digest.h +++ b/ext/digest/digest.h @@ -49,3 +49,10 @@ rb_digest_##name##_finish(void *ctx, unsigned char *ptr) \ https://github.com/ruby/ruby/blob/trunk/ext/digest/digest.h#L49 { \ 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 fdd8b36..dafd38a 100644 --- a/ext/digest/md5/md5init.c +++ b/ext/digest/md5/md5init.c @@ -51,12 +51,10 @@ Init_md5(void) https://github.com/ruby/ruby/blob/trunk/ext/digest/md5/md5init.c#L51 { 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 10d9370..a2c0a02 100644 --- a/ext/digest/rmd160/rmd160init.c +++ b/ext/digest/rmd160/rmd160init.c @@ -49,12 +49,10 @@ Init_rmd160(void) https://github.com/ruby/ruby/blob/trunk/ext/digest/rmd160/rmd160init.c#L49 { 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 e12d297..3adf424 100644 --- a/ext/digest/sha1/sha1init.c +++ b/ext/digest/sha1/sha1init.c @@ -53,12 +53,10 @@ Init_sha1(void) https://github.com/ruby/ruby/blob/trunk/ext/digest/sha1/sha1init.c#L53 { 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 9fd8ece..99450bb 100644 --- a/ext/digest/sha2/sha2init.c +++ b/ext/digest/sha2/sha2init.c @@ -42,11 +42,9 @@ Init_sha2(void) https://github.com/ruby/ruby/blob/trunk/ext/digest/sha2/sha2init.c#L42 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 v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/