From 04a039de2b708b8bbfd6020077dbd3db33798dd3 Mon Sep 17 00:00:00 2001 From: Hans Kristian Rosbach Date: Fri, 26 Jun 2015 15:43:09 +0200 Subject: [PATCH] Whitespace cleanup --- deflate_medium.c | 153 +++++++++++++++++++++++------------------------ deflate_p.h | 4 +- 2 files changed, 78 insertions(+), 79 deletions(-) diff --git a/deflate_medium.c b/deflate_medium.c index 0c724b9e..4e454de3 100644 --- a/deflate_medium.c +++ b/deflate_medium.c @@ -1,5 +1,4 @@ -/* - * The deflate_medium deflate strategy +/* deflate_medium.c -- The deflate_medium deflate strategy * * Copyright (C) 2013 Intel Corporation. All rights reserved. * Authors: @@ -30,97 +29,97 @@ static int tr_tally_lit(deflate_state *s, int c) { } static int emit_match(deflate_state *s, struct match match) { - int flush = 0; - - /* matches that are not long enough we need to emit as litterals */ - if (match.match_length < MIN_MATCH) { - while (match.match_length) { - flush += tr_tally_lit(s, s->window[match.strstart]); - s->lookahead--; - match.strstart++; - match.match_length--; - } - return flush; + int flush = 0; + + /* matches that are not long enough we need to emit as litterals */ + if (match.match_length < MIN_MATCH) { + while (match.match_length) { + flush += tr_tally_lit(s, s->window[match.strstart]); + s->lookahead--; + match.strstart++; + match.match_length--; } + return flush; + } - check_match(s, match.strstart, match.match_start, match.match_length); + check_match(s, match.strstart, match.match_start, match.match_length); - flush += tr_tally_dist(s, match.strstart - match.match_start, match.match_length - MIN_MATCH); + flush += tr_tally_dist(s, match.strstart - match.match_start, match.match_length - MIN_MATCH); - s->lookahead -= match.match_length; - return flush; + s->lookahead -= match.match_length; + return flush; } static void insert_match(deflate_state *s, struct match match) { if (unlikely(s->lookahead <= match.match_length + MIN_MATCH)) return; - /* matches that are not long enough we need to emit as litterals */ - if (match.match_length < MIN_MATCH) { + /* matches that are not long enough we need to emit as litterals */ + if (match.match_length < MIN_MATCH) { #ifdef NOT_TWEAK_COMPILER - while (match.match_length) { - match.strstart++; - match.match_length--; - - if (match.match_length) { - if (match.strstart >= match.orgstart) { - insert_string(s, match.strstart); - } - } - } -#else - if (likely(match.match_length == 1)) { - match.strstart++; - match.match_length = 0; - }else{ - match.strstart++; - match.match_length--; + while (match.match_length) { + match.strstart++; + match.match_length--; + + if (match.match_length) { if (match.strstart >= match.orgstart) { - bulk_insert_str(s, match.strstart, match.match_length); + insert_string(s, match.strstart); } - match.strstart += match.match_length; - match.match_length = 0; } -#endif - return; } +#else + if (likely(match.match_length == 1)) { + match.strstart++; + match.match_length = 0; + }else{ + match.strstart++; + match.match_length--; + if (match.strstart >= match.orgstart) { + bulk_insert_str(s, match.strstart, match.match_length); + } + match.strstart += match.match_length; + match.match_length = 0; + } +#endif + return; + } - /* Insert new strings in the hash table only if the match length - * is not too large. This saves time but degrades compression. - */ - if (match.match_length <= 16* s->max_insert_length && s->lookahead >= MIN_MATCH) { - match.match_length--; /* string at strstart already in table */ - match.strstart++; + /* Insert new strings in the hash table only if the match length + * is not too large. This saves time but degrades compression. + */ + if (match.match_length <= 16* s->max_insert_length && s->lookahead >= MIN_MATCH) { + match.match_length--; /* string at strstart already in table */ + match.strstart++; #ifdef NOT_TWEAK_COMPILER - do { - if (likely(match.strstart >= match.orgstart)) { - insert_string(s, match.strstart); - } - match.strstart++; - /* strstart never exceeds WSIZE-MAX_MATCH, so there are - * always MIN_MATCH bytes ahead. - */ - } while (--match.match_length != 0); + do { + if (likely(match.strstart >= match.orgstart)) { + insert_string(s, match.strstart); + } + match.strstart++; + /* strstart never exceeds WSIZE-MAX_MATCH, so there are + * always MIN_MATCH bytes ahead. + */ + } while (--match.match_length != 0); #else - if (likely(match.strstart >= match.orgstart)) { - bulk_insert_str(s, match.strstart, match.match_length); - } - match.strstart += match.match_length; - match.match_length = 0; + if (likely(match.strstart >= match.orgstart)) { + bulk_insert_str(s, match.strstart, match.match_length); + } + match.strstart += match.match_length; + match.match_length = 0; #endif - } else { - match.strstart += match.match_length; - match.match_length = 0; - s->ins_h = s->window[match.strstart]; - if (match.strstart >= 1) - UPDATE_HASH(s, s->ins_h, match.strstart+2-MIN_MATCH); + } else { + match.strstart += match.match_length; + match.match_length = 0; + s->ins_h = s->window[match.strstart]; + if (match.strstart >= 1) + UPDATE_HASH(s, s->ins_h, match.strstart+2-MIN_MATCH); #if MIN_MATCH != 3 #warning Call UPDATE_HASH() MIN_MATCH-3 more times #endif - /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not - * matter since it will be recomputed at next deflate call. - */ - } + /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not + * matter since it will be recomputed at next deflate call. + */ + } } static void fizzle_matches(deflate_state *s, struct match *current, struct match *next) { @@ -131,7 +130,7 @@ static void fizzle_matches(deflate_state *s, struct match *current, struct match /* step zero: sanity checks */ if (current->match_length <= 1) - return; + return; match = s->window - current->match_length + 1 + next->match_start; orig = s->window - current->match_length + 1 + next->strstart; @@ -140,12 +139,11 @@ static void fizzle_matches(deflate_state *s, struct match *current, struct match if (likely(*match != *orig)) return; - /* - * check the overlap case and just give up. We can do better in theory, - * but unlikely to be worth it + /* check the overlap case and just give up. We can do better in theory, + * but unlikely to be worth it */ if (next->match_start + next->match_length >= current->strstart) - return; + return; c = *current; n = *next; @@ -277,9 +275,10 @@ block_state deflate_medium(deflate_state *s, int flush) { */ next_match.match_length = longest_match(s, hash_head); next_match.match_start = s->match_start; - if (next_match.match_start >= next_match.strstart) + if (next_match.match_start >= next_match.strstart) { /* this can happen due to some restarts */ next_match.match_length = 1; + } if (next_match.match_length < MIN_MATCH) next_match.match_length = 1; else diff --git a/deflate_p.h b/deflate_p.h index 6b135287..2127792e 100644 --- a/deflate_p.h +++ b/deflate_p.h @@ -99,8 +99,8 @@ local inline void bulk_insert_str(deflate_state *const s, Pos startpos, uInt cou _tr_flush_block(s, (s->block_start >= 0L ? \ (char *)&s->window[(unsigned)s->block_start] : \ (char *)Z_NULL), \ - (ulg)((long)s->strstart - s->block_start), \ - (last)); \ + (ulg)((long)s->strstart - s->block_start), \ + (last)); \ s->block_start = s->strstart; \ flush_pending(s->strm); \ Tracev((stderr, "[FLUSH]")); \ -- 2.47.2