Skip to content

Commit

Permalink
simplify cc_print_int64 (twitter#146)
Browse files Browse the repository at this point in the history
* simply cc_print_int64

* use the same return statement as in cc_print_int64()

* disable flaky test until we have a mock timer
  • Loading branch information
thinkingfish authored Apr 1, 2017
1 parent b164fcf commit d4002d7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ matrix:
osx_image: xcode7.1
env: C_COMPILER=clang

# clang 4.2 on osx
- os: osx
osx_image: xcode8.2
env: C_COMPILER=clang
# # clang 4.2 on osx
# - os: osx
# osx_image: xcode8.2
# env: C_COMPILER=clang


before_install:
Expand Down
9 changes: 4 additions & 5 deletions src/cc_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ cc_print_int64_unsafe(char *buf, int64_t n)
d = digits(ab);
_print_uint64(buf, d, n);

return (n < 0) ? d + 1 : d;
return d + (n < 0);
}

size_t
Expand All @@ -86,19 +86,18 @@ cc_print_int64(char *buf, size_t size, int64_t n)
size_t d;
uint64_t ab = abs_int64(n);

d = digits(ab) + (n < 0);
if (size < d) {
d = digits(ab);
if (size < d + (n < 0)) {
return 0;
}

if (n < 0) {
*buf++ = '-';
d--;
}

_print_uint64(buf, d, n);

return (n < 0) ? d + 1 : d;
return d + (n < 0);
}

size_t
Expand Down

0 comments on commit d4002d7

Please sign in to comment.