mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-29 06:51:10 +00:00
textiter: make the FindLogAttrFunc functions clearer
- Return true (found) and false (not found) explicitly. - Set found_offset only when something has been found. find_backward_cursor_pos_func() was a bit different, the while loop had the condition "offset > 0" but the return was "offset >= 0". Probably a micro-optimization, since offset == 0 is always a cursor position. Anyway now the code is the same as the other functions. https://bugzilla.gnome.org/show_bug.cgi?id=618852
This commit is contained in:
parent
37f5f78f81
commit
76f3866bd3
@ -2895,12 +2895,18 @@ find_word_end_func (const PangoLogAttr *attrs,
|
||||
++offset;
|
||||
|
||||
/* Find end of next word */
|
||||
while (offset < len && !attrs[offset].is_word_end)
|
||||
++offset;
|
||||
while (offset < len)
|
||||
{
|
||||
if (attrs[offset].is_word_end)
|
||||
{
|
||||
*found_offset = offset;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
*found_offset = offset;
|
||||
++offset;
|
||||
}
|
||||
|
||||
return offset < len;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -2923,12 +2929,18 @@ find_word_start_func (const PangoLogAttr *attrs,
|
||||
--offset;
|
||||
|
||||
/* Find start of prev word */
|
||||
while (offset >= 0 && !attrs[offset].is_word_start)
|
||||
--offset;
|
||||
while (offset >= 0)
|
||||
{
|
||||
if (attrs[offset].is_word_start)
|
||||
{
|
||||
*found_offset = offset;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
*found_offset = offset;
|
||||
--offset;
|
||||
}
|
||||
|
||||
return offset >= 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -2970,12 +2982,18 @@ find_sentence_end_func (const PangoLogAttr *attrs,
|
||||
++offset;
|
||||
|
||||
/* Find end of next sentence */
|
||||
while (offset < len && !attrs[offset].is_sentence_end)
|
||||
++offset;
|
||||
while (offset < len)
|
||||
{
|
||||
if (attrs[offset].is_sentence_end)
|
||||
{
|
||||
*found_offset = offset;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
*found_offset = offset;
|
||||
++offset;
|
||||
}
|
||||
|
||||
return offset < len;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -2998,12 +3016,18 @@ find_sentence_start_func (const PangoLogAttr *attrs,
|
||||
--offset;
|
||||
|
||||
/* Find start of prev sentence */
|
||||
while (offset >= 0 && !attrs[offset].is_sentence_start)
|
||||
--offset;
|
||||
while (offset >= 0)
|
||||
{
|
||||
if (attrs[offset].is_sentence_start)
|
||||
{
|
||||
*found_offset = offset;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
*found_offset = offset;
|
||||
--offset;
|
||||
}
|
||||
|
||||
return offset >= 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -3556,12 +3580,18 @@ find_forward_cursor_pos_func (const PangoLogAttr *attrs,
|
||||
if (!already_moved_initially)
|
||||
++offset;
|
||||
|
||||
while (offset < len && !attrs[offset].is_cursor_position)
|
||||
++offset;
|
||||
while (offset < len)
|
||||
{
|
||||
if (attrs[offset].is_cursor_position)
|
||||
{
|
||||
*found_offset = offset;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
*found_offset = offset;
|
||||
++offset;
|
||||
}
|
||||
|
||||
return offset < len;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -3574,12 +3604,18 @@ find_backward_cursor_pos_func (const PangoLogAttr *attrs,
|
||||
if (!already_moved_initially)
|
||||
--offset;
|
||||
|
||||
while (offset > 0 && !attrs[offset].is_cursor_position)
|
||||
--offset;
|
||||
while (offset >= 0)
|
||||
{
|
||||
if (attrs[offset].is_cursor_position)
|
||||
{
|
||||
*found_offset = offset;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
*found_offset = offset;
|
||||
--offset;
|
||||
}
|
||||
|
||||
return offset >= 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
Loading…
Reference in New Issue
Block a user