From d0100ddd9fe00197cc846d83e70b7611c57dbf43 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 25 Sep 2021 06:17:54 +0000 Subject: lei: make pkt_op easier-to-use and understand Since switching to SOCK_SEQUENTIAL, we no longer have to use fixed-width records to guarantee atomic reads. Thus we can maintain more human-readable/searchable PktOp opcodes. Furthermore, we can infer the subroutine name in many cases to avoid repeating ourselves by specifying a command-name twice (e.g. $ops->{CMD} => [ \&CMD, $obj ]; can now simply be written as: $ops->{CMD} => [ $obj ] if CMD is a method of $obj. --- lib/PublicInbox/LeiXSearch.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/PublicInbox/LeiXSearch.pm') diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm index 99f887ce..ae9f5881 100644 --- a/lib/PublicInbox/LeiXSearch.pm +++ b/lib/PublicInbox/LeiXSearch.pm @@ -536,16 +536,16 @@ sub do_query { my ($self, $lei) = @_; my $l2m = $lei->{l2m}; my $ops = { - '|' => [ $lei->can('sigpipe_handler'), $lei ], - '!' => [ $lei->can('fail_handler'), $lei ], - '.' => [ \&do_post_augment, $lei ], - '+' => [ \&incr_post_augment, $lei ], + 'sigpipe_handler' => [ $lei ], + 'fail_handler' => [ $lei ], + 'do_post_augment' => [ \&do_post_augment, $lei ], + 'incr_post_augment' => [ \&incr_post_augment, $lei ], '' => [ \&query_done, $lei ], 'mset_progress' => [ \&mset_progress, $lei ], 'l2m_progress' => [ \&l2m_progress, $lei ], - 'x_it' => [ $lei->can('x_it'), $lei ], - 'child_error' => [ $lei->can('child_error'), $lei ], - 'incr_start_query' => [ \&incr_start_query, $self, $l2m ], + 'x_it' => [ $lei ], + 'child_error' => [ $lei ], + 'incr_start_query' => [ $self, $l2m ], }; $lei->{auth}->op_merge($ops, $l2m) if $l2m && $lei->{auth}; my $end = $lei->pkt_op_pair; -- cgit v1.2.3-24-ge0c7