From 966d3efddcb1da6496dd99ee06bce7a985a5419f Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 16 Sep 2024 02:27:15 +0200 Subject: minor search optimization: use SCI_GETRANGEPOINTER * if the buffer gap does not fall into the searched area, the gap will no longer be removed. * If it does fall into the range, there is nothing I can do about it. Only Gnulib's re_search_2() allows searching over two buffers. --- src/search.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/search.c b/src/search.c index 01c598e..fbf15ac 100644 --- a/src/search.c +++ b/src/search.c @@ -463,16 +463,16 @@ teco_pattern2regexp(teco_string_t *pattern, guint codepage, gboolean single_expr } static gboolean -teco_do_search(GRegex *re, gint from, gint to, gint *count, GError **error) +teco_do_search(GRegex *re, gsize from, gsize to, gint *count, GError **error) { g_autoptr(GMatchInfo) info = NULL; - const gchar *buffer = (const gchar *)teco_interface_ssm(SCI_GETCHARACTERPOINTER, 0, 0); + const gchar *buffer = (const gchar *)teco_interface_ssm(SCI_GETRANGEPOINTER, from, to-from); GError *tmp_error = NULL; /* * NOTE: The return boolean does NOT signal whether an error was generated. */ - g_regex_match_full(re, buffer, (gssize)to, from, 0, &info, &tmp_error); + g_regex_match_full(re, buffer, to-from, 0, 0, &info, &tmp_error); if (tmp_error) { g_propagate_error(error, tmp_error); return FALSE; @@ -552,7 +552,7 @@ teco_do_search(GRegex *re, gint from, gint to, gint *count, GError **error) if (matched_from >= 0 && matched_to >= 0) /* match success */ - teco_interface_ssm(SCI_SETSEL, matched_from, matched_to); + teco_interface_ssm(SCI_SETSEL, from+matched_from, from+matched_to); return TRUE; } -- cgit v1.2.3