From 88ccf78b206f7360060c0b1e2c5b9b86b8904134 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 2 Feb 2023 21:54:15 +0200 Subject: [PATCH] ; * src/treesit.c (treesit_predicate_match): Simplify last change. --- src/treesit.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/treesit.c b/src/treesit.c index 52953573061..8e772523cc7 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -2483,8 +2483,8 @@ treesit_predicate_match (Lisp_Object args, struct capture_range captures) uint32_t end_byte_offset = ts_node_end_byte (treesit_node); ptrdiff_t start_byte = visible_beg + start_byte_offset; ptrdiff_t end_byte = visible_beg + end_byte_offset; - ptrdiff_t start_pos = buf_bytepos_to_charpos (buffer, start_byte); - ptrdiff_t end_pos = buf_bytepos_to_charpos (buffer, end_byte); + ptrdiff_t start_pos = BYTE_TO_CHAR (start_byte); + ptrdiff_t end_pos = BYTE_TO_CHAR (end_byte); ptrdiff_t old_begv = BEGV; ptrdiff_t old_begv_byte = BEGV_BYTE; ptrdiff_t old_zv = ZV; @@ -2495,8 +2495,8 @@ treesit_predicate_match (Lisp_Object args, struct capture_range captures) ZV = end_pos; ZV_BYTE = end_byte; - ptrdiff_t val = search_buffer (regexp, start_pos, start_byte, end_pos, end_byte, - 1, 1, Qnil, Qnil, false); + ptrdiff_t val = search_buffer (regexp, start_pos, start_byte, + end_pos, end_byte, 1, 1, Qnil, Qnil, false); BEGV = old_begv; BEGV_BYTE = old_begv_byte; @@ -2505,10 +2505,7 @@ treesit_predicate_match (Lisp_Object args, struct capture_range captures) set_buffer_internal (old_buffer); - if (val > 0) - return true; - else - return false; + return (val > 0); } /* Handles predicate (#pred FN ARG...). Return true if FN returns -- 2.39.2