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/[email protected]
Signed-off-by: Maninder Singh <[email protected]>
Signed-off-by: Vaneet Narang <[email protected]>
Cc: Amit Sahrawat <[email protected]>
Cc: David S. Miller <[email protected]>
Cc: Gustavo A. R. Silva <[email protected]>
Cc: Herbert Xu <[email protected]>
Cc: Joe Perches <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Stephen Rothwell <[email protected]>
  • 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.