diff options
author | Yann Collet <cyan@fb.com> | 2017-03-17 22:51:08 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2017-03-17 22:51:21 (GMT) |
commit | eff6166eb84a7aca764cf310bc9eef23d003c354 (patch) | |
tree | f82e56e867f5d8bcd4012b6c9e3d2b715505cc2d /lib | |
parent | 0d073d4d287b08659eada92c614bec30fa277cd0 (diff) | |
download | lz4-eff6166eb84a7aca764cf310bc9eef23d003c354.zip lz4-eff6166eb84a7aca764cf310bc9eef23d003c354.tar.gz lz4-eff6166eb84a7aca764cf310bc9eef23d003c354.tar.bz2 |
minor price function optimization
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lz4opt.h | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/lz4opt.h b/lib/lz4opt.h index 582aa14..7e2e0f6 100644 --- a/lib/lz4opt.h +++ b/lib/lz4opt.h @@ -36,14 +36,12 @@ #define LZ4_OPT_NUM (1<<12) -typedef struct -{ +typedef struct { int off; int len; } LZ4HC_match_t; -typedef struct -{ +typedef struct { int price; int off; int mlen; @@ -54,8 +52,8 @@ typedef struct /* price in bits */ FORCE_INLINE size_t LZ4HC_literalsPrice(size_t litlen) { - size_t price = 8*litlen; - if (litlen >= (size_t)RUN_MASK) price+=8*(1+(litlen-RUN_MASK)/255); + size_t price = litlen; + if (litlen >= (size_t)RUN_MASK) price += 1+(litlen-RUN_MASK)/255; return price; } @@ -63,12 +61,12 @@ FORCE_INLINE size_t LZ4HC_literalsPrice(size_t litlen) /* requires mlen >= MINMATCH */ FORCE_INLINE size_t LZ4HC_sequencePrice(size_t litlen, size_t mlen) { - size_t price = 16 + 8; /* 16-bit offset + token */ + size_t price = 2 + 1; /* 16-bit offset + token */ price += LZ4HC_literalsPrice(litlen); mlen -= MINMATCH; - if (mlen >= (size_t)ML_MASK) price+=8*(1+(mlen-ML_MASK)/255); + if (mlen >= (size_t)ML_MASK) price+= 1+(mlen-ML_MASK)/255; return price; } |