commit f260f33ccd2ca8852c7d14aa51b6d063ff184f5a parent 7ef68be148e2096c510eabc70302341c3c6540dd Author: z3bra <willy@mailoo.org> Date: Mon Nov 3 15:37:13 2014 Tiny bit of optimisation Diffstat: skroll.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/skroll.c b/skroll.c @@ -37,8 +37,8 @@ void skroll (const char *input) do { /* - * each step of the loop will print the buffer, one byte further after each step. - * using a carriage return, it makes the text scroll out. Magic.. + * each step of the loop will print the buffer, one byte further after + * each step. using a carriage return, it makes the text scroll out. * leading/ending spaces are here to make sure that the text goes from * far right, and goes all the way to far left */ @@ -46,11 +46,10 @@ void skroll (const char *input) { /* print out `number` characters from the buffer ! */ - putc('\r', stdout); write(1, input + offset, number); - /* if we want a new line, let's do it here */ - if (newline) putc('\n', stdout); + /* if we want a new line, do it here, otherwise, carriage return */ + putc(newline ? '\n' : '\r', stdout); /* flush stdout, and wait for the next step */ fflush(stdout);