From 902b4618f20607e7bc78fd29071118f315eef23d Mon Sep 17 00:00:00 2001 From: "Gary E. Miller" Date: Thu, 1 Sep 2016 12:45:09 -0700 Subject: No need to iterate a whole buffer when we know the answer. --- hex.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'hex.c') diff --git a/hex.c b/hex.c index 4d03a698..e03ddc97 100644 --- a/hex.c +++ b/hex.c @@ -30,8 +30,10 @@ const char *gpsd_packetdump(char *scbuf, size_t scbuflen, assert(binbuf != NULL); for (cp = binbuf; cp < binbuf + binbuflen; cp++) - if (!isprint((unsigned char) *cp) && !isspace((unsigned char) *cp)) + if (!isprint((unsigned char) *cp) && !isspace((unsigned char) *cp)) { printable = false; + break; /* no need to keep iterating */ + } if (printable) return binbuf; else -- cgit v1.2.1