facebook / facebook/zstd

Consider unifying inline macros

オープン
#2,461 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
C
スター
27.9k
フォーク
2.6k
平均マージ
1日 3時間
マージ済み PR(30日)
8

説明

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()`

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。