Skip to content

Commit d106053

Browse files
committed
Proc#refined: fix documentation and use rb_cref_t for base_cref
1 parent 325340c commit d106053

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

proc.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,10 @@ enum refinement_memo_index {
374374
static VALUE refinement_memo_map; /* set once under the VM lock */
375375

376376
static bool
377-
refinement_memo_key_match(VALUE memo, VALUE base_cref, long argc, const VALUE *mods)
377+
refinement_memo_key_match(VALUE memo, const rb_cref_t *base_cref, long argc, const VALUE *mods)
378378
{
379379
const VALUE *p = RARRAY_CONST_PTR(memo);
380-
if (p[REFINEMENT_MEMO_BASE_CREF] != base_cref) return false;
380+
if (p[REFINEMENT_MEMO_BASE_CREF] != (VALUE)base_cref) return false;
381381
if (RARRAY_LEN(memo) - REFINEMENT_MEMO_MODS != argc) return false;
382382
for (long i = 0; i < argc; i++) {
383383
if (p[REFINEMENT_MEMO_MODS + i] != mods[i]) return false;
@@ -386,7 +386,7 @@ refinement_memo_key_match(VALUE memo, VALUE base_cref, long argc, const VALUE *m
386386
}
387387

388388
static bool
389-
refinement_memo_lookup(const rb_iseq_t *src_iseq, VALUE base_cref,
389+
refinement_memo_lookup(const rb_iseq_t *src_iseq, const rb_cref_t *base_cref,
390390
long argc, const VALUE *mods,
391391
const rb_iseq_t **iseq_out, const rb_cref_t **cref_out)
392392
{
@@ -422,14 +422,14 @@ refinement_memo_lookup(const rb_iseq_t *src_iseq, VALUE base_cref,
422422
}
423423

424424
static void
425-
refinement_memo_store(const rb_iseq_t *src_iseq, VALUE base_cref,
425+
refinement_memo_store(const rb_iseq_t *src_iseq, const rb_cref_t *base_cref,
426426
long argc, const VALUE *mods,
427427
const rb_iseq_t *copied_iseq, const rb_cref_t *cref)
428428
{
429429
VM_ASSERT(ISEQ_BODY(src_iseq)->type == ISEQ_TYPE_BLOCK);
430430

431431
VALUE memo = rb_ary_hidden_new(REFINEMENT_MEMO_MODS + argc);
432-
rb_ary_push(memo, base_cref);
432+
rb_ary_push(memo, (VALUE)base_cref);
433433
rb_ary_push(memo, (VALUE)copied_iseq);
434434
rb_ary_push(memo, (VALUE)cref);
435435
for (long i = 0; i < argc; i++) {
@@ -501,7 +501,7 @@ refinement_memo_store(const rb_iseq_t *src_iseq, VALUE base_cref,
501501
* nested blocks so that the copy can resolve methods through the refinements
502502
* without affecting the original Proc. Applying refinements therefore
503503
* increases memory use roughly in proportion to the size of the block. The
504-
* copy is cached and reused for the same receiver and the same modules.
504+
* copy is cached and reused for the same block and the same modules.
505505
*/
506506
static VALUE
507507
proc_refined(int argc, VALUE *argv, VALUE self)
@@ -523,14 +523,14 @@ proc_refined(int argc, VALUE *argv, VALUE self)
523523
Check_Type(argv[i], T_MODULE);
524524
}
525525

526-
VALUE base_cref = (VALUE)rb_vm_get_cref(src->block.as.captured.ep);
526+
const rb_cref_t *base_cref = rb_vm_get_cref(src->block.as.captured.ep);
527527
const rb_iseq_t *src_iseq = src->block.as.captured.code.iseq;
528528

529529
const rb_iseq_t *new_iseq;
530530
const rb_cref_t *new_cref;
531531
if (!refinement_memo_lookup(src_iseq, base_cref, argc, argv, &new_iseq, &new_cref)) {
532532
new_iseq = rb_iseq_dup_with_independent_caches(src_iseq);
533-
rb_cref_t *cref = rb_vm_cref_dup((const rb_cref_t *)base_cref);
533+
rb_cref_t *cref = rb_vm_cref_dup(base_cref);
534534
/* rb_using_module_recursive modifies shared subclass lists */
535535
RB_VM_LOCKING() {
536536
for (int i = 0; i < argc; i++) {

0 commit comments

Comments
 (0)