forked from AuroraMiddleware/gtk
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
This commit is contained in:
parent
7f6ae622d3
commit
472fd9a75f
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user