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

Hoisted out get_digest_obj_metadata

This commit is contained in:
Nobuyoshi Nakada 2019-08-22 20:14:59 +09:00
parent 9ffb0548bf
commit 650cd24555
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -573,6 +573,12 @@ get_digest_base_metadata(VALUE klass)
return algo;
}
static rb_digest_metadata_t *
get_digest_obj_metadata(VALUE obj)
{
return get_digest_base_metadata(rb_obj_class(obj));
}
static const rb_data_type_t digest_type = {
"digest",
{0, RUBY_TYPED_DEFAULT_FREE, 0,},
@ -619,8 +625,8 @@ rb_digest_base_copy(VALUE copy, VALUE obj)
rb_check_frozen(copy);
algo = get_digest_base_metadata(rb_obj_class(copy));
if (algo != get_digest_base_metadata(rb_obj_class(obj)))
algo = get_digest_obj_metadata(copy);
if (algo != get_digest_obj_metadata(obj))
rb_raise(rb_eTypeError, "different algorithms");
TypedData_Get_Struct(obj, void, &digest_type, pctx1);
@ -641,7 +647,7 @@ rb_digest_base_reset(VALUE self)
rb_digest_metadata_t *algo;
void *pctx;
algo = get_digest_base_metadata(rb_obj_class(self));
algo = get_digest_obj_metadata(self);
TypedData_Get_Struct(self, void, &digest_type, pctx);
@ -663,7 +669,7 @@ rb_digest_base_update(VALUE self, VALUE str)
rb_digest_metadata_t *algo;
void *pctx;
algo = get_digest_base_metadata(rb_obj_class(self));
algo = get_digest_obj_metadata(self);
TypedData_Get_Struct(self, void, &digest_type, pctx);
@ -682,7 +688,7 @@ rb_digest_base_finish(VALUE self)
void *pctx;
VALUE str;
algo = get_digest_base_metadata(rb_obj_class(self));
algo = get_digest_obj_metadata(self);
TypedData_Get_Struct(self, void, &digest_type, pctx);
@ -705,7 +711,7 @@ rb_digest_base_digest_length(VALUE self)
{
rb_digest_metadata_t *algo;
algo = get_digest_base_metadata(rb_obj_class(self));
algo = get_digest_obj_metadata(self);
return INT2NUM(algo->digest_len);
}
@ -720,7 +726,7 @@ rb_digest_base_block_length(VALUE self)
{
rb_digest_metadata_t *algo;
algo = get_digest_base_metadata(rb_obj_class(self));
algo = get_digest_obj_metadata(self);
return INT2NUM(algo->block_len);
}