Commit 472fd9a7 authored by Sébastien Wilmet's avatar Sébastien Wilmet

textiter: small optimization for find_by_log_attrs()

Use gtk_text_iter_set_line_offset (&tmp_iter, 0) instead of
gtk_text_iter_get_line(). The difference should not be big. In the first
case the line doesn't need to be traversed thanks to the offset 0. For
get_line(), the btree must be traversed.

A temporary iter is needed to not break the behavior. But the behavior
is quite strange, the function works directly on the iter passed as an
argument to the function, even if the function returns FALSE (not
found). So maybe a later commit will fix this strange behavior.

https://bugzilla.gnome.org/show_bug.cgi?id=629129
parent 7f6ae622
......@@ -3131,14 +3131,18 @@ find_by_log_attrs (GtkTextIter *iter,
}
else
{
/* TODO optimize this part */
/* go to end of previous line. need to check that
* line is > 0 because backward_line snaps to start of
* line 0 if it's on line 0
GtkTextIter tmp_iter = *iter;
/* Go to end of previous line. First go to the current line offset 0,
* because backward_line() snaps to start of line 0 if iter is already
* on line 0.
*/
if (gtk_text_iter_get_line (iter) > 0 &&
gtk_text_iter_backward_line (iter))
gtk_text_iter_set_line_offset (&tmp_iter, 0);
if (gtk_text_iter_backward_line (&tmp_iter))
{
*iter = tmp_iter;
if (!gtk_text_iter_ends_line (iter))
gtk_text_iter_forward_to_line_end (iter);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment