From c4692f08f90105e5ed4fb0e2cbb771e637d94b2f Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 24 Jul 2017 16:43:41 +1000 Subject: [PATCH] Fix testnet diffs, optimising for the common case of mainnet. --- src/libckpool.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libckpool.c b/src/libckpool.c index 20c64370..611ee77f 100644 --- a/src/libckpool.c +++ b/src/libckpool.c @@ -1760,12 +1760,16 @@ int ser_number(uchar *s, int32_t val) int32_t *i32 = (int32_t *)&s[1]; int len; - if (val < 128) + /* Optimise for the common case for mainnet */ + if (likely(val > 32767 && val < 8388608)) + len = 3; + else if (val < 17) { + s[0] = 0x50 + val; + return 1; + } else if (val < 128) len = 1; - else if (val < 16512) + else if (val < 32768) len = 2; - else if (val < 2113664) - len = 3; else len = 4; *i32 = htole32(val);