Skip to content

Commit

Permalink
Add BrotliCopyPreloadedSymbols function.
Browse files Browse the repository at this point in the history
Add a single trivial use to avoid complier warning.

PiperOrigin-RevId: 671098230
  • Loading branch information
TocarIP authored and copybara-github committed Sep 4, 2024
1 parent 39bcecf commit d6dc555
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions c/dec/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1899,6 +1899,22 @@ static BROTLI_INLINE BROTLI_BOOL CheckInputAmount(
} \
}

/* Reads up to limit symbols from br and copies them into ringbuffer,
starting from pos. Caller must ensure that this is safe. */
static BROTLI_INLINE void BrotliCopyPreloadedSymbols(BrotliBitReader* br,
brotli_reg_t* bits,
brotli_reg_t* value,
BrotliDecoderState* s,
int pos,
int limit) {
int pos_limit = pos + limit;
for (; pos < pos_limit; pos++) {
s->ringbuffer[pos] =
(uint8_t)ReadPreloadedSymbol(s->literal_htree, br, bits, value);
BROTLI_LOG_ARRAY_INDEX(s->ringbuffer, pos);
}
}

static BROTLI_INLINE BrotliDecoderErrorCode ProcessCommandsInternal(
int safe, BrotliDecoderState* s) {
int pos = s->pos;
Expand Down Expand Up @@ -1969,8 +1985,7 @@ static BROTLI_INLINE BrotliDecoderErrorCode ProcessCommandsInternal(
goto NextLiteralBlock;
}
if (!safe) {
s->ringbuffer[pos] =
(uint8_t)ReadPreloadedSymbol(s->literal_htree, br, &bits, &value);
BrotliCopyPreloadedSymbols(br, &bits, &value, s, pos, 1);
} else {
brotli_reg_t literal;
if (!SafeReadSymbol(s->literal_htree, br, &literal)) {
Expand Down

0 comments on commit d6dc555

Please sign in to comment.