Skip to content

Commit

Permalink
Use _p suffix for query methods
Browse files Browse the repository at this point in the history
To match a convention used in the Ruby codebase, use _p at the end of a
method for methods ending in a question mark rather than _query.
  • Loading branch information
mudge committed Oct 21, 2022
1 parent ac29a22 commit 397acf9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ext/re2/re2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ static VALUE re2_regexp_match(int argc, VALUE *argv, VALUE self) {
*
* @return [Boolean] whether the match was successful
*/
static VALUE re2_regexp_match_query(VALUE self, VALUE text) {
static VALUE re2_regexp_match_p(VALUE self, VALUE text) {
VALUE argv[2];
argv[0] = text;
argv[1] = INT2FIX(0);
Expand Down Expand Up @@ -1666,6 +1666,8 @@ void Init_re2(void) {
RUBY_METHOD_FUNC(re2_matchdata_to_s), 0);
rb_define_method(re2_cMatchData, "inspect",
RUBY_METHOD_FUNC(re2_matchdata_inspect), 0);
rb_define_method(re2_cMatchData, "deconstruct",
RUBY_METHOD_FUNC(re2_matchdata_deconstruct), 0);

rb_define_method(re2_cScanner, "string",
RUBY_METHOD_FUNC(re2_scanner_string), 0);
Expand Down Expand Up @@ -1696,11 +1698,11 @@ void Init_re2(void) {
rb_define_method(re2_cRegexp, "match", RUBY_METHOD_FUNC(re2_regexp_match),
-1);
rb_define_method(re2_cRegexp, "match?",
RUBY_METHOD_FUNC(re2_regexp_match_query), 1);
RUBY_METHOD_FUNC(re2_regexp_match_p), 1);
rb_define_method(re2_cRegexp, "=~",
RUBY_METHOD_FUNC(re2_regexp_match_query), 1);
RUBY_METHOD_FUNC(re2_regexp_match_p), 1);
rb_define_method(re2_cRegexp, "===",
RUBY_METHOD_FUNC(re2_regexp_match_query), 1);
RUBY_METHOD_FUNC(re2_regexp_match_p), 1);
rb_define_method(re2_cRegexp, "scan",
RUBY_METHOD_FUNC(re2_regexp_scan), 1);
rb_define_method(re2_cRegexp, "to_s", RUBY_METHOD_FUNC(re2_regexp_to_s), 0);
Expand Down

0 comments on commit 397acf9

Please sign in to comment.