Author | Jamozed <[email protected]> |
Date | 2020-07-02 02:46:42 |
Commit | 3e21bfd4448dc1c89bf6bb076021e48cbc15d0f0 |
Parent | 4fd512b6f182dcd8fa0fa14a1b0d7307650769ff |
cat: Move buffer onto stack
Moving the buffer onto the stack improves performance slightly.
Diffstat
M | src/cat.c | | | 8 | ++++---- |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cat.c b/src/cat.c index 090eb60..12164d7 100644 --- a/src/cat.c +++ b/src/cat.c @@ -1,4 +1,4 @@ -// cat.c, version 1.0.2 +// cat.c, version 1.0.3 // OMKOV coreutils implementation of POSIX cat // Copyright (C) 2020, Jakob Wakeling // All rights reserved. @@ -41,7 +41,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #include <stdio.h> #include <string.h> -static char stdbuf[BUFSIZ * 16]; +#define VERSION "1.0.3" static inline int cat(const char *file); @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) { } static inline int cat(const char *file) { - FILE *fi; + char stdbuf[BUFSIZ * 16]; FILE *fi; if (file[0] == '-' && file[1] == 0) { fi = stdin; } else if (!(fi = fopen(file, "r"))) { return 1; } @@ -98,7 +98,7 @@ static void help(void) { } static void version(void) { - puts("OMKOV coreutils cat, version 1.0.2"); + puts("OMKOV coreutils cat, version " VERSION); puts("Copyright (C) 2020, Jakob Wakeling"); puts("All rights reserved."); puts("OMKOV Permissive Licence (https://www.omkov.net/OLPE)");