summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSquibid <me@zacharyscheiman.com>2024-12-19 13:41:57 -0600
committerSquibid <me@zacharyscheiman.com>2024-12-19 13:41:57 -0600
commit2a6385fa36106f3fc9c23b705a3cca1d31f196f5 (patch)
treecf2c521a6fcf6e36dd1fbd61cb3ff2c9241b9dae
parent363f15abd39d92e3aa027f66f7cb0cfafb6f3aae (diff)
downloadXD-2a6385fa36106f3fc9c23b705a3cca1d31f196f5.tar.gz
XD-2a6385fa36106f3fc9c23b705a3cca1d31f196f5.tar.bz2
XD-2a6385fa36106f3fc9c23b705a3cca1d31f196f5.zip
optimizing...
replace printf with fwrite to make it ever so slightly faster
Diffstat (limited to '')
-rw-r--r--XD.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/XD.c b/XD.c
index 31c1dd1..92c3095 100644
--- a/XD.c
+++ b/XD.c
@@ -9,6 +9,8 @@
#include <git2.h>
#endif
+#define P(X) fwrite(X, 1, 1, stdout)
+
#ifdef ERR
void
l(const char *fmt, ...)
@@ -182,25 +184,25 @@ main(int argc, char *argv[])
if (git_ok) {
/* change the eyes depending on the current git repo's status */
if (has_stashes(repo)) {
- printf("8"); /* goggle eyes if we have some stashed changes */
+ P("8"); /* goggle eyes if we have some stashed changes */
} else if (git_repository_is_empty(repo)) {
- printf("B"); /* sunglasses if we're in a new repo with no HEAD */
+ P("B"); /* sunglasses if we're in a new repo with no HEAD */
} else {
- printf(";"); /* wink when we're in a git repo */
+ P(";"); /* wink when we're in a git repo */
}
/* change the nose depending on the current git repo's status */
if (has_staged(repo)) {
- printf("*"); /* change to broken nose for staged changes */
+ P("*"); /* change to broken nose for staged changes */
} else if (has_untracked(repo)) {
- printf("^"); /* add a little nose when there are untracked changes in the repo */
+ P("^"); /* add a little nose when there are untracked changes in the repo */
} else if (git_repository_head_detached(repo)) {
- printf("-"); /* add a minus nose when the HEAD is detached */
+ P("-"); /* add a minus nose when the HEAD is detached */
}
} else
#endif
if (1) {
- printf(":");
+ P(":");
}
/* get exit code from user args */
@@ -211,14 +213,14 @@ main(int argc, char *argv[])
/* change mouth based on exit code */
if (code >= 0) {
switch (code) {
- case 0: printf(")"); break; /* all good */
- case 130: printf("O"); break; /* Ctrl-c pressed (SIGTERM) */
- case 126: printf("P"); break; /* permission denied */
- case 127: printf("/"); break; /* command not found */
- default: printf("("); break; /* all other codes (usually the program saying it has failed) */
+ case 0: P(")"); break; /* all good */
+ case 130: P("O"); break; /* Ctrl-c pressed (SIGTERM) */
+ case 126: P("P"); break; /* permission denied */
+ case 127: P("/"); break; /* command not found */
+ default: P("("); break; /* all other codes (usually the program saying it has failed) */
}
} else {
- printf("|"); /* no code info */
+ P("|"); /* no code info */
}
#ifdef GIT