summaryrefslogtreecommitdiff
path: root/insert_string_tpl.h
diff options
context:
space:
mode:
authorHans Kristian Rosbach <hk-git@circlestorm.org>2025-11-30 22:31:49 +0100
committerHans Kristian Rosbach <hk-github@circlestorm.org>2025-12-07 12:41:30 +0100
commitbf95fa0fba9764608aa4164d9ead5839d2edde87 (patch)
tree47a0d2c7df4e1070705df678bd8dd0879d3d5ce6 /insert_string_tpl.h
parente2cd66c048de41a05a13cf5e6b32a2b72577c82b (diff)
downloadProject-Tick-bf95fa0fba9764608aa4164d9ead5839d2edde87.tar.gz
Project-Tick-bf95fa0fba9764608aa4164d9ead5839d2edde87.zip
Inline all uses of quick_insert_string*/quick_insert_value*.
Inline all uses of update_hash*. Inline insert_string into deflate_quick, deflate_fast and deflate_medium. Remove insert_string from deflate_state Use local function pointer for insert_string. Fix level check to actually check level and not `s->max_chain_length <= 1024`.
Diffstat (limited to 'insert_string_tpl.h')
-rw-r--r--insert_string_tpl.h20
1 files changed, 4 insertions, 16 deletions
diff --git a/insert_string_tpl.h b/insert_string_tpl.h
index 64cc743458..04a9b0a6b6 100644
--- a/insert_string_tpl.h
+++ b/insert_string_tpl.h
@@ -1,6 +1,3 @@
-#ifndef INSERT_STRING_H_
-#define INSERT_STRING_H_
-
/* insert_string_tpl.h -- Private insert_string functions shared with more than
* one insert string implementation
*
@@ -22,14 +19,6 @@
*
*/
-#include "zmemory.h"
-
-#ifndef HASH_CALC_OFFSET
-# define HASH_CALC_OFFSET 0
-#endif
-#ifndef HASH_CALC_MASK
-# define HASH_CALC_MASK HASH_MASK
-#endif
#ifndef HASH_CALC_READ
# if BYTE_ORDER == LITTLE_ENDIAN
# define HASH_CALC_READ \
@@ -46,7 +35,7 @@
* input characters, so that a running hash key can be computed from the
* previous key instead of complete recalculation each time.
*/
-Z_INTERNAL uint32_t UPDATE_HASH(uint32_t h, uint32_t val) {
+Z_FORCEINLINE static uint32_t UPDATE_HASH(uint32_t h, uint32_t val) {
HASH_CALC(h, val);
return h & HASH_CALC_MASK;
}
@@ -56,7 +45,7 @@ Z_INTERNAL uint32_t UPDATE_HASH(uint32_t h, uint32_t val) {
* to the previous head of the hash chain (the most recent string with same hash key).
* Return the previous length of the hash chain.
*/
-Z_INTERNAL Pos QUICK_INSERT_VALUE(deflate_state *const s, uint32_t str, uint32_t val) {
+Z_FORCEINLINE static Pos QUICK_INSERT_VALUE(deflate_state *const s, uint32_t str, uint32_t val) {
uint32_t hm;
Pos head;
@@ -78,7 +67,7 @@ Z_INTERNAL Pos QUICK_INSERT_VALUE(deflate_state *const s, uint32_t str, uint32_t
* of the hash chain (the most recent string with same hash key). Return
* the previous length of the hash chain.
*/
-Z_INTERNAL Pos QUICK_INSERT_STRING(deflate_state *const s, uint32_t str) {
+Z_FORCEINLINE static Pos QUICK_INSERT_STRING(deflate_state *const s, uint32_t str) {
uint8_t *strstart = s->window + str + HASH_CALC_OFFSET;
uint32_t val, hm;
Pos head;
@@ -105,7 +94,7 @@ Z_INTERNAL Pos QUICK_INSERT_STRING(deflate_state *const s, uint32_t str) {
* input characters and the first STD_MIN_MATCH bytes of str are valid
* (except for the last STD_MIN_MATCH-1 bytes of the input file).
*/
-Z_INTERNAL void INSERT_STRING(deflate_state *const s, uint32_t str, uint32_t count) {
+Z_FORCEINLINE static void INSERT_STRING(deflate_state *const s, uint32_t str, uint32_t count) {
uint8_t *strstart = s->window + str + HASH_CALC_OFFSET;
uint8_t *strend = strstart + count;
@@ -130,4 +119,3 @@ Z_INTERNAL void INSERT_STRING(deflate_state *const s, uint32_t str, uint32_t cou
}
}
}
-#endif