Skip to content

Commit

Permalink
zstd: use U16 data type for rankPos
Browse files Browse the repository at this point in the history
rankPos structure variables value can not be more than 512.  So it can
easily be declared as U16 rather than U32.

It will reduce stack usage of HUF_sort from 256 bytes to 128 bytes

original:
e92ddbf0        push    {r4, r5, r6, r7, r8, r9, fp, ip, lr, pc}
e24cb004        sub     fp, ip, #4
e24ddc01        sub     sp, sp, torvalds#256    ; 0x100

changed:
e92ddbf0        push    {r4, r5, r6, r7, r8, r9, fp, ip, lr, pc}
e24cb004        sub     fp, ip, #4
e24dd080        sub     sp, sp, torvalds#128    ; 0x80

Link: http://lkml.kernel.org/r/1559552526-4317-3-git-send-email-maninder1.s@samsung.com
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Vaneet Narang <v.narang@samsung.com>
Cc: Amit Sahrawat <a.sahrawat@samsung.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Gustavo A. R. Silva <gustavo@embeddedor.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Joe Perches <joe@perches.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: <pankaj.m@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
  • Loading branch information
maninder42 authored and sfrothwell committed Jun 5, 2019
1 parent 3a42bcf commit c88d8bb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/zstd/huf_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ static U32 HUF_setMaxHeight(nodeElt *huffNode, U32 lastNonNull, U32 maxNbBits)
}

typedef struct {
U32 base;
U32 curr;
U16 base;
U16 curr;
} rankPos;

static void HUF_sort(nodeElt *huffNode, const U32 *count, U32 maxSymbolValue)
Expand Down

0 comments on commit c88d8bb

Please sign in to comment.