aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-06 14:56:13 +0200
committerMax Kellermann <max@duempel.org>2008-10-06 14:56:13 +0200
commit32ac49ed95f5959d2206bf4e710350d435a04d05 (patch)
treede526f099d12e975682e61bc85c612491987ba1a /src
parenteb28e1a9398a5423e247eeda12594fa0f0a0136b (diff)
downloadmpd-32ac49ed95f5959d2206bf4e710350d435a04d05.tar.gz
mpd-32ac49ed95f5959d2206bf4e710350d435a04d05.tar.xz
mpd-32ac49ed95f5959d2206bf4e710350d435a04d05.zip
wreadln: return early from cursor movement functions
Unclutter these functions by removing one indent level.
Diffstat (limited to 'src')
-rw-r--r--src/wreadln.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/wreadln.c b/src/wreadln.c
index 6c66895f7..59026ed08 100644
--- a/src/wreadln.c
+++ b/src/wreadln.c
@@ -74,22 +74,24 @@ wrln_gcmp_post_cb_t wrln_post_completion_callback = NULL;
/* move the cursor one step to the right */
static inline void cursor_move_right(struct wreadln *wr)
{
- if (wr->cursor < strlen(wr->line)) {
- ++wr->cursor;
- if (wr->cursor >= (size_t)wr->width &&
- wr->start < wr->cursor - wr->width + 1)
- ++wr->start;
- }
+ if (wr->line[wr->cursor] == 0)
+ return;
+
+ ++wr->cursor;
+ if (wr->cursor >= (size_t)wr->width &&
+ wr->start < wr->cursor - wr->width + 1)
+ ++wr->start;
}
/* move the cursor one step to the left */
static inline void cursor_move_left(struct wreadln *wr)
{
- if (wr->cursor > 0) {
- if (wr->cursor == wr->start && wr->start > 0)
- --wr->start;
- --wr->cursor;
- }
+ if (wr->cursor == 0)
+ return;
+
+ if (wr->cursor == wr->start && wr->start > 0)
+ --wr->start;
+ --wr->cursor;
}
/* move the cursor to the end of the line */