facebook / facebook/zstd

Consider unifying inline macros

Aperta
#2,461 1 commento 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
C
Stelle
27.9k
Fork
2.6k
Merge medio
1g 3h
PR unite (30g)
8

Descrizione

There are three inline macros, `HINT_INLINE`, `MEM_STATIC`, `FORCE_INLINE_TEMPLATE`.

It would be nice they can be unified, such as:
* `HINT_INLINE`, only add `inline` keyword.
* `FORCE_INLINE`, force inline.
* `EXPAND_INLINE`, when `ZSTD_LIB_MINIFY` macro **is not** defined, it forces inline function; when `ZSTD_LIB_MINIFY` macro **is** defined, it's empty (no inline).

BTW, `HINT_INLINE` is force inline currently, the name is a bit confusing.
```c
/**
* HINT_INLINE is used to help the compiler generate better code. It is *not*
* used for "templates", so it can be tweaked based on the compilers
* performance.
*
* gcc-4.8 and gcc-4.9 have been shown to benefit from leaving off the
* always_inline attribute.
*
* clang up to 5.0.0 (trunk) benefit tremendously from the always_inline
* attribute.
*/
#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 8 && __GNUC__ < 5
# define HINT_INLINE static INLINE_KEYWORD
#else
# define HINT_INLINE static INLINE_KEYWORD FORCE_INLINE_ATTR
#endif
```
These functions are using `HINT_INLINE`:

\lib\compress\zstd_compress_internal.h:
`ZSTD_storeSeq()`

\lib\decompress\huf_decompress.c:
`HUF_decodeStreamX1()`
`HUF_decodeStreamX2()`

\lib\decompress\zstd_decompress_block.c:
`ZSTD_overlapCopy8()`
`ZSTD_execSequence()`

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.