diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-09-16 02:27:15 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-09-16 02:27:15 +0200 |
commit | 966d3efddcb1da6496dd99ee06bce7a985a5419f (patch) | |
tree | c48b89fd8c17afdeeebe47728d717ac9ae8d6490 /src | |
parent | ded9a02e5c1b2ad1a1224e7dcfb3b1550e712666 (diff) | |
download | sciteco-966d3efddcb1da6496dd99ee06bce7a985a5419f.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/search.c | 8 |
1 files changed, 4 insertions, 4 deletions
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; } |