ruby-changes:47776
From: mame <ko1@a...>
Date: Thu, 14 Sep 2017 19:45:10 +0900 (JST)
Subject: [ruby-changes:47776] mame:r59894 (trunk): ext/coverage/coverage.c: use long instead of int for coverage site id
mame 2017-09-14 19:45:04 +0900 (Thu, 14 Sep 2017) New Revision: 59894 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59894 Log: ext/coverage/coverage.c: use long instead of int for coverage site id Coverage generates unique ID numbers for each branch and each method. Use long instead of int for the IDs. I don't want to see 2^32 branches and methods in one file, but just in case... Modified files: trunk/ext/coverage/coverage.c Index: ext/coverage/coverage.c =================================================================== --- ext/coverage/coverage.c (revision 59893) +++ ext/coverage/coverage.c (revision 59894) @@ -73,19 +73,20 @@ branch_coverage(VALUE branches) https://github.com/ruby/ruby/blob/trunk/ext/coverage/coverage.c#L73 VALUE ret = rb_hash_new(); VALUE structure = rb_ary_dup(RARRAY_AREF(branches, 0)); VALUE counters = rb_ary_dup(RARRAY_AREF(branches, 1)); - int i, j, id = 0; + int i, j; + long id = 0; for (i = 0; i < RARRAY_LEN(structure); i++) { VALUE branches = RARRAY_AREF(structure, i); VALUE base_type = RARRAY_AREF(branches, 0); VALUE base_lineno = RARRAY_AREF(branches, 1); VALUE children = rb_hash_new(); - rb_hash_aset(ret, rb_ary_new_from_args(3, base_type, INT2FIX(id++), base_lineno), children); + rb_hash_aset(ret, rb_ary_new_from_args(3, base_type, LONG2FIX(id++), base_lineno), children); for (j = 2; j < RARRAY_LEN(branches); j += 3) { VALUE target_label = RARRAY_AREF(branches, j); VALUE target_lineno = RARRAY_AREF(branches, j + 1); int idx = FIX2INT(RARRAY_AREF(branches, j + 2)); - rb_hash_aset(children, rb_ary_new_from_args(3, target_label, INT2FIX(id++), target_lineno), RARRAY_AREF(counters, idx)); + rb_hash_aset(children, rb_ary_new_from_args(3, target_label, LONG2FIX(id++), target_lineno), RARRAY_AREF(counters, idx)); } } @@ -96,13 +97,14 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ext/coverage/coverage.c#L97 method_coverage(VALUE methods) { VALUE ret = rb_hash_new(); - int i, id = 0; + int i; + long id = 0; for (i = 0; i < RARRAY_LEN(methods); ) { VALUE method_name = RARRAY_AREF(methods, i++); VALUE lineno = RARRAY_AREF(methods, i++); VALUE counter = RARRAY_AREF(methods, i++); - rb_hash_aset(ret, rb_ary_new_from_args(3, method_name, INT2FIX(id++), lineno), counter); + rb_hash_aset(ret, rb_ary_new_from_args(3, method_name, LONG2FIX(id++), lineno), counter); } return ret; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/