mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
regint.h: Reduce the frequency of rb_thread_check_ints
edc8576a65
checks interrupt at every
backtrack, which brought significant overhead.
This change makes the check only once every 128 backtracks.
This commit is contained in:
parent
1357b14750
commit
9112cf4ae7
Notes:
git
2022-03-24 09:47:51 +09:00
2 changed files with 10 additions and 1 deletions
|
@ -421,6 +421,7 @@ onig_region_copy(OnigRegion* to, const OnigRegion* from)
|
|||
(msa).start = (arg_start);\
|
||||
(msa).gpos = (arg_gpos);\
|
||||
(msa).best_len = ONIG_MISMATCH;\
|
||||
(msa).counter = 0;\
|
||||
} while(0)
|
||||
#else
|
||||
# define MATCH_ARG_INIT(msa, arg_option, arg_region, arg_start, arg_gpos) do {\
|
||||
|
@ -429,6 +430,7 @@ onig_region_copy(OnigRegion* to, const OnigRegion* from)
|
|||
(msa).region = (arg_region);\
|
||||
(msa).start = (arg_start);\
|
||||
(msa).gpos = (arg_gpos);\
|
||||
(msa).counter = 0;\
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
|
|
9
regint.h
9
regint.h
|
@ -148,7 +148,13 @@
|
|||
|
||||
#ifdef RUBY
|
||||
|
||||
# define CHECK_INTERRUPT_IN_MATCH_AT rb_thread_check_ints()
|
||||
# define CHECK_INTERRUPT_IN_MATCH_AT do { \
|
||||
msa->counter++; \
|
||||
if (msa->counter >= 128) { \
|
||||
msa->counter = 0; \
|
||||
rb_thread_check_ints(); \
|
||||
} \
|
||||
} while(0)
|
||||
# define onig_st_init_table st_init_table
|
||||
# define onig_st_init_table_with_size st_init_table_with_size
|
||||
# define onig_st_init_numtable st_init_numtable
|
||||
|
@ -870,6 +876,7 @@ typedef struct {
|
|||
void* state_check_buff;
|
||||
int state_check_buff_size;
|
||||
#endif
|
||||
int counter;
|
||||
} OnigMatchArg;
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue