Skip to content

Commit

Permalink
Speed up check for illegal top-level op
Browse files Browse the repository at this point in the history
Calling List::Util::first here keeps showing up as a hotspot on our NYTProf output, so just use a regex instead.
  • Loading branch information
Larry Leszczynski committed May 18, 2021
1 parent 7bed2f6 commit 8d3d33c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/SQL/Abstract.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ our $AUTOLOAD;

# special operators (-in, -between). May be extended/overridden by user.
# See section WHERE: BUILTIN SPECIAL OPERATORS below for implementation
my @BUILTIN_SPECIAL_OPS = (
{regex => qr/^ (?: not \s )? between $/ix, handler => sub { die "NOPE" }},
{regex => qr/^ is (?: \s+ not )? $/ix, handler => sub { die "NOPE" }},
{regex => qr/^ (?: not \s )? in $/ix, handler => sub { die "NOPE" }},
{regex => qr/^ ident $/ix, handler => sub { die "NOPE" }},
{regex => qr/^ value $/ix, handler => sub { die "NOPE" }},
);
my $BUILTIN_SPECIAL_OPS_re = qr/
^ (?:
(?: (?: not \s )? (?: between | in ) ) |
(?: is (?: \s+ not )? ) |
ident |
value
) $
/ix;

#======================================================================
# DEBUGGING AND ERROR REPORTING
Expand Down Expand Up @@ -1109,7 +1110,7 @@ sub _expand_hashpair_op {
$is_special
or (
$self->{disable_old_special_ops}
and List::Util::first { $wsop =~ $_->{regex} } @BUILTIN_SPECIAL_OPS
and $wsop =~ $BUILTIN_SPECIAL_OPS_re
)
)
) {
Expand Down

0 comments on commit 8d3d33c

Please sign in to comment.