Skip to content

Commit 1a035c9

Browse files
authored
Apply suggestions from code review
1 parent b12d42d commit 1a035c9

File tree

1 file changed

+11
-25
lines changed

1 file changed

+11
-25
lines changed

Modules/_json.c

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,9 @@ static PyObject *
215215
ascii_escape_unicode(PyObject *pystr)
216216
{
217217
/* Take a PyUnicode pystr and return a new ASCII-only escaped PyUnicode */
218-
Py_ssize_t input_chars;
219-
const void *input;
220-
int kind;
221-
222-
input_chars = PyUnicode_GET_LENGTH(pystr);
223-
input = PyUnicode_DATA(pystr);
224-
kind = PyUnicode_KIND(pystr);
218+
Py_ssize_t input_chars = PyUnicode_GET_LENGTH(pystr);
219+
const void *input = PyUnicode_DATA(pystr);
220+
int kind = PyUnicode_KIND(pystr);
225221

226222
Py_ssize_t output_size = ascii_escape_size(input, kind, input_chars);
227223
if (output_size < 0) {
@@ -362,15 +358,10 @@ static PyObject *
362358
escape_unicode(PyObject *pystr)
363359
{
364360
/* Take a PyUnicode pystr and return a new escaped PyUnicode */
365-
Py_ssize_t input_chars;
366-
const void *input;
367-
int kind;
368-
Py_UCS4 maxchar;
369-
370-
maxchar = PyUnicode_MAX_CHAR_VALUE(pystr);
371-
input_chars = PyUnicode_GET_LENGTH(pystr);
372-
input = PyUnicode_DATA(pystr);
373-
kind = PyUnicode_KIND(pystr);
361+
Py_ssize_t input_chars = PyUnicode_GET_LENGTH(pystr);
362+
const void *input = PyUnicode_DATA(pystr);
363+
int kind = PyUnicode_KIND(pystr);
364+
Py_UCS4 maxchar = PyUnicode_MAX_CHAR_VALUE(pystr);
374365

375366
Py_ssize_t output_size = escape_size(input, kind, input_chars);
376367
if (output_size < 0) {
@@ -383,15 +374,10 @@ escape_unicode(PyObject *pystr)
383374
static int
384375
write_escaped_unicode(PyUnicodeWriter *writer, PyObject *pystr)
385376
{
386-
Py_ssize_t input_chars;
387-
const void *input;
388-
int kind;
389-
Py_UCS4 maxchar;
390-
391-
maxchar = PyUnicode_MAX_CHAR_VALUE(pystr);
392-
input_chars = PyUnicode_GET_LENGTH(pystr);
393-
input = PyUnicode_DATA(pystr);
394-
kind = PyUnicode_KIND(pystr);
377+
Py_ssize_t input_chars = PyUnicode_GET_LENGTH(pystr);
378+
const void *input = PyUnicode_DATA(pystr);
379+
int kind = PyUnicode_KIND(pystr);
380+
Py_UCS4 maxchar = PyUnicode_MAX_CHAR_VALUE(pystr);
395381

396382
Py_ssize_t output_size = escape_size(input, kind, input_chars);
397383
if (output_size < 0) {

0 commit comments

Comments
 (0)