From 09d112d1aff37668008bacd8e6ca614120b3b4f8 Mon Sep 17 00:00:00 2001 From: master-vic Date: Mon, 18 May 2015 12:16:25 -0400 Subject: [PATCH 1/2] Update echo.c Adding an empty space for the first fprintf and removing the if statement. The purpose is to eliminate argc executions of the if statement and argc-1 calls of fprintf. The echo result will be the same as before but the produced machine code will have less instructions and less function calls for more performance. --- client/echo.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/client/echo.c b/client/echo.c index 7117da2..1f39d54 100644 --- a/client/echo.c +++ b/client/echo.c @@ -35,11 +35,8 @@ int main(int argc, char **argv) { int i; for (i= 1; i < argc; i++) - { - fprintf(stdout, "%s", argv[i]); - if (i < argc - 1) - fprintf(stdout, " "); - } + fprintf(stdout, "%s ", argv[i]); + fprintf(stdout, " "); return 0; } From 38b3c770399e2f7b682958c28d7ef8836264e4d5 Mon Sep 17 00:00:00 2001 From: master-vic Date: Thu, 21 May 2015 02:55:40 -0400 Subject: [PATCH 2/2] Update echo.c --- client/echo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/echo.c b/client/echo.c index 1f39d54..1f1c577 100644 --- a/client/echo.c +++ b/client/echo.c @@ -34,9 +34,9 @@ int main(int argc, char **argv) { int i; - for (i= 1; i < argc; i++) + for (i= 1; i < argc-1; i++) fprintf(stdout, "%s ", argv[i]); - fprintf(stdout, " "); + fprintf(stdout, "%s ", argv[i]); return 0; }