From a47f598d77ac97f9fe89fe16aa8bcab4fd262c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lourens=20Naud=C3=A9?= Date: Sat, 20 Apr 2019 00:44:51 +0100 Subject: Reduce ONIG_NREGION from 10 to 4: power of 2 and testing revealed most pattern matches are less than or equal to 4 results Closes: https://github.com/ruby/ruby/pull/2135 --- gc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gc.c') diff --git a/gc.c b/gc.c index 5bd0cf75b6..b629c03dc0 100644 --- a/gc.c +++ b/gc.c @@ -2436,6 +2436,17 @@ obj_free(rb_objspace_t *objspace, VALUE obj) case T_MATCH: if (RANY(obj)->as.match.rmatch) { struct rmatch *rm = RANY(obj)->as.match.rmatch; +#if USE_DEBUG_COUNTER + if (rm->regs.num_regs >= 8) { + RB_DEBUG_COUNTER_INC(obj_match_ge8); + } + else if (rm->regs.num_regs >= 4) { + RB_DEBUG_COUNTER_INC(obj_match_ge4); + } + else if (rm->regs.num_regs >= 1) { + RB_DEBUG_COUNTER_INC(obj_match_under4); + } +#endif onig_region_free(&rm->regs, 0); if (rm->char_offset) xfree(rm->char_offset); -- cgit v1.2.3