@@ -131,7 +131,8 @@ _PyZstd_load_d_dict(ZstdDecompressor *self, PyObject *dict)
131
131
ret = PyObject_IsInstance (dict , (PyObject * )mod_state -> ZstdDict_type );
132
132
if (ret < 0 ) {
133
133
return -1 ;
134
- } else if (ret > 0 ) {
134
+ }
135
+ else if (ret > 0 ) {
135
136
/* When decompressing, use digested dictionary by default. */
136
137
zd = (ZstdDict * )dict ;
137
138
type = DICT_TYPE_DIGESTED ;
@@ -145,7 +146,8 @@ _PyZstd_load_d_dict(ZstdDecompressor *self, PyObject *dict)
145
146
(PyObject * )mod_state -> ZstdDict_type );
146
147
if (ret < 0 ) {
147
148
return -1 ;
148
- } else if (ret > 0 ) {
149
+ }
150
+ else if (ret > 0 ) {
149
151
/* type == -1 may indicate an error. */
150
152
type = PyLong_AsInt (PyTuple_GET_ITEM (dict , 1 ));
151
153
if (type == DICT_TYPE_DIGESTED ||
@@ -175,23 +177,26 @@ _PyZstd_load_d_dict(ZstdDecompressor *self, PyObject *dict)
175
177
Py_BEGIN_CRITICAL_SECTION (self );
176
178
zstd_ret = ZSTD_DCtx_refDDict (self -> dctx , d_dict );
177
179
Py_END_CRITICAL_SECTION ();
178
- } else if (type == DICT_TYPE_UNDIGESTED ) {
180
+ }
181
+ else if (type == DICT_TYPE_UNDIGESTED ) {
179
182
/* Load a dictionary */
180
183
Py_BEGIN_CRITICAL_SECTION2 (self , zd );
181
184
zstd_ret = ZSTD_DCtx_loadDictionary (
182
185
self -> dctx ,
183
186
PyBytes_AS_STRING (zd -> dict_content ),
184
187
Py_SIZE (zd -> dict_content ));
185
188
Py_END_CRITICAL_SECTION2 ();
186
- } else if (type == DICT_TYPE_PREFIX ) {
189
+ }
190
+ else if (type == DICT_TYPE_PREFIX ) {
187
191
/* Load a prefix */
188
192
Py_BEGIN_CRITICAL_SECTION2 (self , zd );
189
193
zstd_ret = ZSTD_DCtx_refPrefix (
190
194
self -> dctx ,
191
195
PyBytes_AS_STRING (zd -> dict_content ),
192
196
Py_SIZE (zd -> dict_content ));
193
197
Py_END_CRITICAL_SECTION2 ();
194
- } else {
198
+ }
199
+ else {
195
200
/* Impossible code path */
196
201
PyErr_SetString (PyExc_SystemError ,
197
202
"load_d_dict() impossible code path" );
@@ -296,7 +301,8 @@ decompress_impl(ZstdDecompressor *self, ZSTD_inBuffer *in,
296
301
if (_OutputBuffer_InitWithSize (& buffer , & out , max_length , initial_size ) < 0 ) {
297
302
goto error ;
298
303
}
299
- } else {
304
+ }
305
+ else {
300
306
if (_OutputBuffer_InitAndGrow (& buffer , & out , max_length ) < 0 ) {
301
307
goto error ;
302
308
}
@@ -325,7 +331,8 @@ decompress_impl(ZstdDecompressor *self, ZSTD_inBuffer *in,
325
331
self -> eof = 1 ;
326
332
break ;
327
333
}
328
- } else if (type == TYPE_ENDLESS_DECOMPRESSOR ) {
334
+ }
335
+ else if (type == TYPE_ENDLESS_DECOMPRESSOR ) {
329
336
/* decompress() function supports multiple frames */
330
337
self -> at_frame_edge = (zstd_ret == 0 ) ? 1 : 0 ;
331
338
@@ -351,7 +358,8 @@ decompress_impl(ZstdDecompressor *self, ZSTD_inBuffer *in,
351
358
}
352
359
assert (out .pos == 0 );
353
360
354
- } else if (in -> pos == in -> size ) {
361
+ }
362
+ else if (in -> pos == in -> size ) {
355
363
/* Finished */
356
364
break ;
357
365
}
@@ -406,7 +414,8 @@ stream_decompress(ZstdDecompressor *self, Py_buffer *data, Py_ssize_t max_length
406
414
assert (ret == NULL );
407
415
goto success ;
408
416
}
409
- } else if (type == TYPE_ENDLESS_DECOMPRESSOR ) {
417
+ }
418
+ else if (type == TYPE_ENDLESS_DECOMPRESSOR ) {
410
419
/* Fast path for the first frame */
411
420
if (self -> at_frame_edge && self -> in_begin == self -> in_end ) {
412
421
/* Read decompressed size */
@@ -435,7 +444,8 @@ stream_decompress(ZstdDecompressor *self, Py_buffer *data, Py_ssize_t max_length
435
444
in .src = data -> buf ;
436
445
in .size = data -> len ;
437
446
in .pos = 0 ;
438
- } else if (data -> len == 0 ) {
447
+ }
448
+ else if (data -> len == 0 ) {
439
449
/* Has unconsumed data, fast path for b'' */
440
450
assert (self -> in_begin < self -> in_end );
441
451
@@ -444,7 +454,8 @@ stream_decompress(ZstdDecompressor *self, Py_buffer *data, Py_ssize_t max_length
444
454
in .src = self -> input_buffer + self -> in_begin ;
445
455
in .size = self -> in_end - self -> in_begin ;
446
456
in .pos = 0 ;
447
- } else {
457
+ }
458
+ else {
448
459
/* Has unconsumed data */
449
460
use_input_buffer = 1 ;
450
461
@@ -485,7 +496,8 @@ stream_decompress(ZstdDecompressor *self, Py_buffer *data, Py_ssize_t max_length
485
496
/* Set begin & end position */
486
497
self -> in_begin = 0 ;
487
498
self -> in_end = used_now ;
488
- } else if (avail_now < (size_t ) data -> len ) {
499
+ }
500
+ else if (avail_now < (size_t ) data -> len ) {
489
501
/* Move unconsumed data to the beginning.
490
502
Overlap is possible, so use memmove(). */
491
503
memmove (self -> input_buffer ,
@@ -520,13 +532,16 @@ stream_decompress(ZstdDecompressor *self, Py_buffer *data, Py_ssize_t max_length
520
532
if (type == TYPE_DECOMPRESSOR ) {
521
533
if (Py_SIZE (ret ) == max_length || self -> eof ) {
522
534
self -> needs_input = 0 ;
523
- } else {
535
+ }
536
+ else {
524
537
self -> needs_input = 1 ;
525
538
}
526
- } else if (type == TYPE_ENDLESS_DECOMPRESSOR ) {
539
+ }
540
+ else if (type == TYPE_ENDLESS_DECOMPRESSOR ) {
527
541
if (Py_SIZE (ret ) == max_length && !self -> at_frame_edge ) {
528
542
self -> needs_input = 0 ;
529
- } else {
543
+ }
544
+ else {
530
545
self -> needs_input = 1 ;
531
546
}
532
547
}
@@ -536,7 +551,8 @@ stream_decompress(ZstdDecompressor *self, Py_buffer *data, Py_ssize_t max_length
536
551
self -> in_begin = 0 ;
537
552
self -> in_end = 0 ;
538
553
}
539
- } else {
554
+ }
555
+ else {
540
556
size_t data_size = in .size - in .pos ;
541
557
542
558
self -> needs_input = 0 ;
@@ -570,7 +586,8 @@ stream_decompress(ZstdDecompressor *self, Py_buffer *data, Py_ssize_t max_length
570
586
memcpy (self -> input_buffer , (char * )in .src + in .pos , data_size );
571
587
self -> in_begin = 0 ;
572
588
self -> in_end = data_size ;
573
- } else {
589
+ }
590
+ else {
574
591
/* Use input buffer */
575
592
self -> in_begin += in .pos ;
576
593
}
@@ -726,14 +743,16 @@ _zstd_ZstdDecompressor_unused_data_get_impl(ZstdDecompressor *self)
726
743
}
727
744
ret = mod_state -> empty_bytes ;
728
745
Py_INCREF (ret );
729
- } else {
746
+ }
747
+ else {
730
748
if (self -> unused_data == NULL ) {
731
749
self -> unused_data = PyBytes_FromStringAndSize (
732
750
self -> input_buffer + self -> in_begin ,
733
751
self -> in_end - self -> in_begin );
734
752
ret = self -> unused_data ;
735
753
Py_XINCREF (ret );
736
- } else {
754
+ }
755
+ else {
737
756
ret = self -> unused_data ;
738
757
Py_INCREF (ret );
739
758
}
0 commit comments