diff options
author | Franklin Wei <me@fwei.tk> | 2018-07-12 21:02:20 +0000 |
---|---|---|
committer | Franklin Wei <me@fwei.tk> | 2018-07-12 21:02:20 +0000 |
commit | 00e5cc796efc779288f7418eb7f7211e2b1023a7 (patch) | |
tree | a3856ae91ef0a07e15f9302c8409a17682b5089e | |
parent | be0d0fac2fad4ade1a1f81f34644e84042f2578d (diff) | |
download | csaa-00e5cc796efc779288f7418eb7f7211e2b1023a7.zip csaa-00e5cc796efc779288f7418eb7f7211e2b1023a7.tar.gz csaa-00e5cc796efc779288f7418eb7f7211e2b1023a7.tar.bz2 csaa-00e5cc796efc779288f7418eb7f7211e2b1023a7.tar.xz |
Inline bintree_sibling() and bintree_parent()
No point in incurring a function call overhead for such simple functions.
-rw-r--r-- | crypto.c | 12 | ||||
-rw-r--r-- | crypto.h | 12 |
2 files changed, 12 insertions, 12 deletions
@@ -111,18 +111,6 @@ hash_t merkle_compute(hash_t node, const hash_t *comp, const int *orders, size_t return parent; } -/* Given a node's index, return the index of the parent in an array - * representation of a binary tree. */ -uint64_t bintree_parent(uint64_t idx) -{ - return (idx - 1) / 2; -} - -uint64_t bintree_sibling(uint64_t idx) -{ - return idx + ((idx & 1) ? 1 : -1); -} - /* Calculate the indicies of the complementary nodes to a * leaf. `leafidx' is 0 for the rightmost leaf node. This function * will return an array with a length equal to the number of levels in @@ -48,6 +48,18 @@ int *bintree_complement_ordersonly(uint64_t leafidx, int logleaves); * given leaf node. Will be ordered from nearest relative to root. */ uint64_t *bintree_ancestors(uint64_t leafidx, int logleaves); +/* Given a node's index, return the index of the parent in an array + * representation of a binary tree. */ +static inline uint64_t bintree_parent(uint64_t idx) +{ + return (idx - 1) / 2; +} + +static inline uint64_t bintree_sibling(uint64_t idx) +{ + return idx + ((idx & 1) ? 1 : -1); +} + uint64_t bintree_parent(uint64_t idx); uint64_t bintree_sibling(uint64_t idx); |