diff options
| author | Tyge Løvset <[email protected]> | 2020-10-08 14:21:06 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2020-10-08 14:21:06 +0200 |
| commit | ab81979f713c71ec164f6bce033038ba09e1e829 (patch) | |
| tree | 2bd51c1ffddb47b8ea19ef17ba113f212c62b973 | |
| parent | 5a6bb1f5061a6ac75d70edf90f75dd976cfaba7d (diff) | |
| download | STC-modified-ab81979f713c71ec164f6bce033038ba09e1e829.tar.gz STC-modified-ab81979f713c71ec164f6bce033038ba09e1e829.zip | |
Minor opt.
| -rw-r--r-- | stc/cpqueue.h | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/stc/cpqueue.h b/stc/cpqueue.h index 19e225a9..685c4fc8 100644 --- a/stc/cpqueue.h +++ b/stc/cpqueue.h @@ -92,8 +92,7 @@ _cpqueue_##X##_sift_down(cpqueue_##X##_value_t* arr, size_t i, size_t n) { \
size_t r = i, c = i << 1; \
while (c <= n) { \
- if (c < n && ctype##_value_compare(&arr[c], &arr[c + 1]) cmpOpr 0) \
- ++c; \
+ c += (c < n && ctype##_value_compare(&arr[c], &arr[c + 1]) cmpOpr 0); \
if (ctype##_value_compare(&arr[r], &arr[c]) cmpOpr 0) { \
cpqueue_##X##_value_t tmp = arr[r]; arr[r] = arr[c]; arr[r = c] = tmp; \
} else \
@@ -104,7 +103,7 @@ \
STC_API void \
cpqueue_##X##_make_heap(cpqueue_##X* self) { \
- size_t n = cpqueue_##X##_size(*self); \
+ size_t n = cpqueue_##X##_size(*self); \
cpqueue_##X##_value_t *arr = self->data - 1; \
for (size_t k = n >> 1; k != 0; --k) \
_cpqueue_##X##_sift_down(arr, k, n); \
|
