From cd6df5fb3c1e9b965071d6a92ed1c7d4a938560f Mon Sep 17 00:00:00 2001 From: mame Date: Sun, 3 Sep 2017 14:26:06 +0000 Subject: Refactor the internal data format for coverage measurement To prepare new measuring targets: branch and method coverages. So far, iseq->coverage was an array of counts executed for line coverage. Now, it is a three-element array for each measuring target, whose first element is an array for line coverage. The second element is planned for branch coverage, and the third will be for method coverage. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/coverage/coverage.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'ext') diff --git a/ext/coverage/coverage.c b/ext/coverage/coverage.c index d2077a969e..643c2455db 100644 --- a/ext/coverage/coverage.c +++ b/ext/coverage/coverage.c @@ -24,7 +24,7 @@ rb_coverage_start(VALUE klass) if (!RTEST(coverages)) { coverages = rb_hash_new(); rb_obj_hide(coverages); - rb_set_coverages(coverages); + rb_set_coverages(coverages, COVERAGE_TARGET_LINES); } return Qnil; } @@ -35,9 +35,12 @@ coverage_peek_result_i(st_data_t key, st_data_t val, st_data_t h) VALUE path = (VALUE)key; VALUE coverage = (VALUE)val; VALUE coverages = (VALUE)h; - coverage = rb_ary_dup(coverage); - rb_ary_freeze(coverage); - rb_hash_aset(coverages, path, coverage); + VALUE lines = RARRAY_AREF(coverage, COVERAGE_INDEX_LINES); + if (lines) { + lines = rb_ary_dup(lines); + rb_ary_freeze(lines); + } + rb_hash_aset(coverages, path, lines); return ST_CONTINUE; } -- cgit v1.2.3