From 0e453b26542776f237e1c977db793f5bd24b6d0d Mon Sep 17 00:00:00 2001 From: Adam Gashlin Date: Mon, 12 Jun 2023 00:18:18 -0700 Subject: [PATCH] Fallthrough in LZ4 state machine for a MSVC bug This works around an issue in "Microsoft (R) C/C++ Optimizing Compiler Version 19.36.32532 for x64" with /O2. It seems to have trouble tying together the states, this perhaps links the data and control flow more simply. --- src/meta/xnb_lz4mg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/meta/xnb_lz4mg.h b/src/meta/xnb_lz4mg.h index dc61510d..9a2e98aa 100644 --- a/src/meta/xnb_lz4mg.h +++ b/src/meta/xnb_lz4mg.h @@ -154,7 +154,7 @@ static int lz4mg_decompress(lz4mg_stream_t* strm) { } while (next_len == LZ4MG_VARLEN_CONTINUE); ctx->state = SET_MATCH; - break; + // Falthrough for MSVC case SET_MATCH: ctx->match_len += LZ4MG_MIN_MATCH_LEN; @@ -164,7 +164,7 @@ static int lz4mg_decompress(lz4mg_stream_t* strm) { ctx->match_pos = LZ4MG_WINDOW_SIZE + ctx->match_pos; ctx->state = COPY_MATCH; - break; + // Fallthrough for MSVC case COPY_MATCH: while (ctx->match_len > 0) {