Skip to content

Commit d9ee203

Browse files
committed
refactor: rename quality -> level
1 parent 21f29e9 commit d9ee203

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

brotli.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static void php_brotli_context_init(php_brotli_context *ctx)
109109
}
110110

111111
static int php_brotli_context_create_encoder_ex(php_brotli_context *ctx,
112-
long quality, int lgwin,
112+
long level, int lgwin,
113113
long mode, int fail)
114114
{
115115
ctx->encoder = BrotliEncoderCreateInstance(NULL, NULL, NULL);
@@ -119,18 +119,18 @@ static int php_brotli_context_create_encoder_ex(php_brotli_context *ctx,
119119
return FAILURE;
120120
}
121121

122-
if (quality < BROTLI_MIN_QUALITY || quality > BROTLI_MAX_QUALITY) {
122+
if (level < BROTLI_MIN_QUALITY || level > BROTLI_MAX_QUALITY) {
123123
php_error_docref(NULL, E_WARNING,
124-
"%s compression quality (%ld)%s:"
124+
"%s compression level (%ld)%s:"
125125
" must be within %d..%d",
126126
(fail ? "failed to" : "brotli: set"),
127-
(long)quality,
127+
(long)level,
128128
(fail ? "": " to BROTLI_COMPRESS_LEVEL_DEFAULT"),
129129
BROTLI_MIN_QUALITY, BROTLI_MAX_QUALITY);
130130
if (fail) {
131131
return FAILURE;
132132
}
133-
quality = BROTLI_DEFAULT_QUALITY;
133+
level = BROTLI_DEFAULT_QUALITY;
134134
}
135135
if (lgwin == 0) {
136136
lgwin = BROTLI_DEFAULT_WINDOW;
@@ -152,7 +152,7 @@ static int php_brotli_context_create_encoder_ex(php_brotli_context *ctx,
152152
mode = BROTLI_MODE_GENERIC;
153153
}
154154

155-
if (!BrotliEncoderSetParameter(ctx->encoder, BROTLI_PARAM_QUALITY, quality)
155+
if (!BrotliEncoderSetParameter(ctx->encoder, BROTLI_PARAM_QUALITY, level)
156156
|| !BrotliEncoderSetParameter(ctx->encoder, BROTLI_PARAM_LGWIN, lgwin)
157157
|| !BrotliEncoderSetParameter(ctx->encoder, BROTLI_PARAM_MODE, mode)) {
158158
php_error_docref(NULL, E_WARNING,
@@ -164,8 +164,8 @@ static int php_brotli_context_create_encoder_ex(php_brotli_context *ctx,
164164
return SUCCESS;
165165
}
166166

167-
#define php_brotli_context_create_encoder(ctx, quality, lgwin, mode) \
168-
php_brotli_context_create_encoder_ex(ctx, quality, lgwin, mode, 0)
167+
#define php_brotli_context_create_encoder(ctx, level, lgwin, mode) \
168+
php_brotli_context_create_encoder_ex(ctx, level, lgwin, mode, 0)
169169

170170
static int php_brotli_context_create_decoder(php_brotli_context *ctx)
171171
{
@@ -228,7 +228,7 @@ static int php_brotli_output_encoding(void)
228228
static int php_brotli_output_handler(void **handler_context,
229229
php_output_context *output_context)
230230
{
231-
long quality = BROTLI_DEFAULT_QUALITY;
231+
long level = BROTLI_DEFAULT_QUALITY;
232232
php_brotli_context *ctx = *(php_brotli_context **)handler_context;
233233

234234
if (!php_brotli_output_encoding()) {
@@ -246,13 +246,13 @@ static int php_brotli_output_handler(void **handler_context,
246246
return FAILURE;
247247
}
248248

249-
quality = BROTLI_G(output_compression_level);
250-
if (quality < BROTLI_MIN_QUALITY || quality > BROTLI_MAX_QUALITY) {
251-
quality = BROTLI_DEFAULT_QUALITY;
249+
level = BROTLI_G(output_compression_level);
250+
if (level < BROTLI_MIN_QUALITY || level > BROTLI_MAX_QUALITY) {
251+
level = BROTLI_DEFAULT_QUALITY;
252252
}
253253

254254
if (output_context->op & PHP_OUTPUT_HANDLER_START) {
255-
if (php_brotli_context_create_encoder(ctx, quality, 0, 0) != SUCCESS) {
255+
if (php_brotli_context_create_encoder(ctx, level, 0, 0) != SUCCESS) {
256256
return FAILURE;
257257
}
258258
}
@@ -325,7 +325,7 @@ static int php_brotli_output_handler(void **handler_context,
325325
} else {
326326
// restart
327327
if (php_brotli_context_create_encoder(ctx,
328-
quality, 0, 0) != SUCCESS) {
328+
level, 0, 0) != SUCCESS) {
329329
return FAILURE;
330330
}
331331
}
@@ -1501,7 +1501,7 @@ static ZEND_FUNCTION(brotli_uncompress_add)
15011501
static int APC_SERIALIZER_NAME(brotli)(APC_SERIALIZER_ARGS)
15021502
{
15031503
int result;
1504-
int lgwin = BROTLI_DEFAULT_WINDOW, quality = BROTLI_DEFAULT_QUALITY;
1504+
int lgwin = BROTLI_DEFAULT_WINDOW, level = BROTLI_DEFAULT_QUALITY;
15051505
php_serialize_data_t var_hash;
15061506
smart_str var = {0};
15071507
BrotliEncoderMode mode = BROTLI_MODE_GENERIC;
@@ -1516,7 +1516,7 @@ static int APC_SERIALIZER_NAME(brotli)(APC_SERIALIZER_ARGS)
15161516
*buf_len = BrotliEncoderMaxCompressedSize(ZSTR_LEN(var.s));
15171517
*buf = (char*) emalloc(*buf_len);
15181518

1519-
if (!BrotliEncoderCompress(quality, lgwin, mode,
1519+
if (!BrotliEncoderCompress(level, lgwin, mode,
15201520
ZSTR_LEN(var.s),
15211521
(const uint8_t*) ZSTR_VAL(var.s),
15221522
buf_len, (uint8_t*) *buf)) {

0 commit comments

Comments
 (0)