| 3382 | |
| 3383 | #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN |
| 3384 | static mz_bool tdefl_compress_fast(tdefl_compressor *d) { |
| 3385 | // Faster, minimally featured LZRW1-style match+parse loop with better |
| 3386 | // register utilization. Intended for applications where raw throughput is |
| 3387 | // valued more highly than ratio. |
| 3388 | mz_uint lookahead_pos = d->m_lookahead_pos, |
| 3389 | lookahead_size = d->m_lookahead_size, dict_size = d->m_dict_size, |
| 3390 | total_lz_bytes = d->m_total_lz_bytes, |
| 3391 | num_flags_left = d->m_num_flags_left; |
| 3392 | mz_uint8 *pLZ_code_buf = d->m_pLZ_code_buf, *pLZ_flags = d->m_pLZ_flags; |
| 3393 | mz_uint cur_pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK; |
| 3394 | |
| 3395 | while ((d->m_src_buf_left) || ((d->m_flush) && (lookahead_size))) { |
| 3396 | const mz_uint TDEFL_COMP_FAST_LOOKAHEAD_SIZE = 4096; |
| 3397 | mz_uint dst_pos = |
| 3398 | (lookahead_pos + lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK; |
| 3399 | mz_uint num_bytes_to_process = (mz_uint)MZ_MIN( |
| 3400 | d->m_src_buf_left, TDEFL_COMP_FAST_LOOKAHEAD_SIZE - lookahead_size); |
| 3401 | d->m_src_buf_left -= num_bytes_to_process; |
| 3402 | lookahead_size += num_bytes_to_process; |
| 3403 | |
| 3404 | while (num_bytes_to_process) { |
| 3405 | mz_uint32 n = MZ_MIN(TDEFL_LZ_DICT_SIZE - dst_pos, num_bytes_to_process); |
| 3406 | memcpy(d->m_dict + dst_pos, d->m_pSrc, n); |
| 3407 | if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) |
| 3408 | memcpy(d->m_dict + TDEFL_LZ_DICT_SIZE + dst_pos, d->m_pSrc, |
| 3409 | MZ_MIN(n, (TDEFL_MAX_MATCH_LEN - 1) - dst_pos)); |
| 3410 | d->m_pSrc += n; |
| 3411 | dst_pos = (dst_pos + n) & TDEFL_LZ_DICT_SIZE_MASK; |
| 3412 | num_bytes_to_process -= n; |
| 3413 | } |
| 3414 | |
| 3415 | dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - lookahead_size, dict_size); |
| 3416 | if ((!d->m_flush) && (lookahead_size < TDEFL_COMP_FAST_LOOKAHEAD_SIZE)) |
| 3417 | break; |
| 3418 | |
| 3419 | while (lookahead_size >= 4) { |
| 3420 | mz_uint cur_match_dist, cur_match_len = 1; |
| 3421 | mz_uint8 *pCur_dict = d->m_dict + cur_pos; |
| 3422 | mz_uint first_trigram = (*(const mz_uint32 *)pCur_dict) & 0xFFFFFF; |
| 3423 | mz_uint hash = |
| 3424 | (first_trigram ^ (first_trigram >> (24 - (TDEFL_LZ_HASH_BITS - 8)))) & |
| 3425 | TDEFL_LEVEL1_HASH_SIZE_MASK; |
| 3426 | mz_uint probe_pos = d->m_hash[hash]; |
| 3427 | d->m_hash[hash] = (mz_uint16)lookahead_pos; |
| 3428 | |
| 3429 | if (((cur_match_dist = (mz_uint16)(lookahead_pos - probe_pos)) <= |
| 3430 | dict_size) && |
| 3431 | ((*(const mz_uint32 *)(d->m_dict + |
| 3432 | (probe_pos &= TDEFL_LZ_DICT_SIZE_MASK)) & |
| 3433 | 0xFFFFFF) == first_trigram)) { |
| 3434 | const mz_uint16 *p = (const mz_uint16 *)pCur_dict; |
| 3435 | const mz_uint16 *q = (const mz_uint16 *)(d->m_dict + probe_pos); |
| 3436 | mz_uint32 probe_len = 32; |
| 3437 | do { |
| 3438 | } while ((TDEFL_READ_UNALIGNED_WORD(++p) == |
| 3439 | TDEFL_READ_UNALIGNED_WORD(++q)) && |
| 3440 | (TDEFL_READ_UNALIGNED_WORD(++p) == |
| 3441 | TDEFL_READ_UNALIGNED_WORD(++q)) && |
no test coverage detected