diff options
author | Yusuke Endoh <[email protected]> | 2022-03-24 01:57:34 +0900 |
---|---|---|
committer | Yusuke Endoh <[email protected]> | 2022-03-24 09:47:22 +0900 |
commit | 9112cf4ae7f7ea8ab33c282aa02eec812421aeab (patch) | |
tree | 1ccef0a305de038f6d5e3c2cffe85d809f958fdf /regint.h | |
parent | 1357b14750275d2f2d13896688064e1a243007dd (diff) |
regint.h: Reduce the frequency of rb_thread_check_ints
edc8576a65b7082597d45a694434261ec3ac0d9e checks interrupt at every
backtrack, which brought significant overhead.
This change makes the check only once every 128 backtracks.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5697
Diffstat (limited to 'regint.h')
-rw-r--r-- | regint.h | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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; |