summaryrefslogtreecommitdiff
path: root/hex.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2016-09-01 12:45:09 -0700
committerGary E. Miller <gem@rellim.com>2016-09-01 12:45:09 -0700
commit902b4618f20607e7bc78fd29071118f315eef23d (patch)
treeffde5c1aa851907b53c23b2a927b96911971a422 /hex.c
parent8f74020d331f0aa1fd165f2d9490fc66022745c2 (diff)
downloadgpsd-902b4618f20607e7bc78fd29071118f315eef23d.tar.gz
No need to iterate a whole buffer when we know the answer.
Diffstat (limited to 'hex.c')
-rw-r--r--hex.c4
1 files changed, 3 insertions, 1 deletions
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