FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GH-132983: remove empty_bytes from _zstd module state by AA-Turner · Pull Request #133785 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (2) .h  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
9 changes: 0 additions & 9 deletions Modules/_zstd/_zstdmodule.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,6 @@ do { \
_zstd_state* const mod_state = get_zstd_state(m);

/* Reusable objects & variables */
mod_state->empty_bytes = PyBytes_FromStringAndSize(NULL, 0);
if (mod_state->empty_bytes == NULL) {
return -1;
}

mod_state->CParameter_type = NULL;
mod_state->DParameter_type = NULL;

Expand Down Expand Up @@ -694,8 +689,6 @@ _zstd_traverse(PyObject *module, visitproc visit, void *arg)
{
_zstd_state* const mod_state = get_zstd_state(module);

Py_VISIT(mod_state->empty_bytes);

Py_VISIT(mod_state->ZstdDict_type);
Py_VISIT(mod_state->ZstdCompressor_type);

Expand All @@ -713,8 +706,6 @@ _zstd_clear(PyObject *module)
{
_zstd_state* const mod_state = get_zstd_state(module);

Py_CLEAR(mod_state->empty_bytes);

Py_CLEAR(mod_state->ZstdDict_type);
Py_CLEAR(mod_state->ZstdCompressor_type);

Expand Down
2 changes: 0 additions & 2 deletions Modules/_zstd/_zstdmodule.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ extern PyType_Spec zstd_compressor_type_spec;
extern PyType_Spec zstd_decompressor_type_spec;

struct _zstd_state {
PyObject *empty_bytes;

PyTypeObject *ZstdDict_type;
PyTypeObject *ZstdCompressor_type;
PyTypeObject *ZstdDecompressor_type;
Expand Down
20 changes: 2 additions & 18 deletions Modules/_zstd/decompressor.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,7 @@ decompress_impl(ZstdDecompressor *self, ZSTD_inBuffer *in,
/* The first AFE check for setting .at_frame_edge flag */
if (type == TYPE_ENDLESS_DECOMPRESSOR) {
if (self->at_frame_edge && in->pos == in->size) {
_zstd_state* const mod_state = PyType_GetModuleState(Py_TYPE(self));
if (mod_state == NULL) {
return NULL;
}
ret = mod_state->empty_bytes;
Py_INCREF(ret);
return ret;
return Py_GetConstant(Py_CONSTANT_EMPTY_BYTES);
}
}

Expand Down Expand Up @@ -747,16 +741,8 @@ _zstd_ZstdDecompressor_unused_data_get_impl(ZstdDecompressor *self)
{
PyObject *ret;

/* Thread-safe code */
Py_BEGIN_CRITICAL_SECTION(self);

if (!self->eof) {
_zstd_state* const mod_state = PyType_GetModuleState(Py_TYPE(self));
if (mod_state == NULL) {
return NULL;
}
ret = mod_state->empty_bytes;
Py_INCREF(ret);
return Py_GetConstant(Py_CONSTANT_EMPTY_BYTES);
}
else {
if (self->unused_data == NULL) {
Expand All @@ -772,8 +758,6 @@ _zstd_ZstdDecompressor_unused_data_get_impl(ZstdDecompressor *self)
}
}

Py_END_CRITICAL_SECTION();

return ret;
}

Expand Down

Back | FazBrowse Home | New Git URL