зеркало из https://github.com/github/ruby.git
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
This commit is contained in:
Родитель
7d805e67f3
Коммит
a47f598d77
|
@ -0,0 +1 @@
|
|||
1000000.times { /(.)(.)(\d+)(\d)/.match("THX1138.") }
|
|
@ -0,0 +1 @@
|
|||
1000000.times { 'haystack'.match(/hay/) }
|
|
@ -177,6 +177,9 @@ RB_DEBUG_COUNTER(gc_isptr_maybe)
|
|||
* * hash_under4: has under 4 entries
|
||||
* * hash_ge4: has n entries (4<=n<8)
|
||||
* * hash_ge8: has n entries (8<=n)
|
||||
* * match_under4: has under 4 oniguruma regions allocated
|
||||
* * match_ge4: has n regions allocated (4<=n<8)
|
||||
* * match_ge8: has n regions allocated (8<=n)
|
||||
* * data_empty: T_DATA but no memory free.
|
||||
* * data_xfree: free'ed by xfree().
|
||||
* * data_imm_free: free'ed immediately.
|
||||
|
@ -225,6 +228,9 @@ RB_DEBUG_COUNTER(obj_data_xfree)
|
|||
RB_DEBUG_COUNTER(obj_data_imm_free)
|
||||
RB_DEBUG_COUNTER(obj_data_zombie)
|
||||
|
||||
RB_DEBUG_COUNTER(obj_match_under4)
|
||||
RB_DEBUG_COUNTER(obj_match_ge4)
|
||||
RB_DEBUG_COUNTER(obj_match_ge8)
|
||||
RB_DEBUG_COUNTER(obj_match_ptr)
|
||||
RB_DEBUG_COUNTER(obj_file_ptr)
|
||||
RB_DEBUG_COUNTER(obj_bignum_ptr)
|
||||
|
|
11
gc.c
11
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);
|
||||
|
|
|
@ -434,7 +434,7 @@ int onigenc_str_bytelen_null(OnigEncoding enc, const OnigUChar* p);
|
|||
/* PART: regular expression */
|
||||
|
||||
/* config parameters */
|
||||
#define ONIG_NREGION 10
|
||||
#define ONIG_NREGION 4
|
||||
#define ONIG_MAX_CAPTURE_GROUP_NUM 32767
|
||||
#define ONIG_MAX_BACKREF_NUM 1000
|
||||
#define ONIG_MAX_REPEAT_NUM 100000
|
||||
|
|
Загрузка…
Ссылка в новой задаче