@@ -207,24 +207,20 @@ int PyUnicode_ToLower(Py_UCS4 ch, Py_UCS4 *res, int size)
207207 int n = ctype -> lower >> 24 ;
208208 int i ;
209209 for (i = 0 ; i < n ; i ++ ) {
210- if (res != NULL ) {
211- if (i >= size ) {
212- PyErr_SetString (PyExc_ValueError , "output buffer is too small" );
213- return -1 ;
214- }
215- res [i ] = _PyUnicode_ExtendedCase [index + i ];
210+ if (i >= size ) {
211+ PyErr_SetString (PyExc_ValueError , "output buffer is too small" );
212+ return -1 ;
216213 }
214+ res [i ] = _PyUnicode_ExtendedCase [index + i ];
217215 }
218216 return n ;
219217 }
220218
221- if (res != NULL ) {
222- if (0 >= size ) {
223- PyErr_SetString (PyExc_ValueError , "output buffer is too small" );
224- return -1 ;
225- }
226- res [0 ] = ch + ctype -> lower ;
219+ if (0 >= size ) {
220+ PyErr_SetString (PyExc_ValueError , "output buffer is too small" );
221+ return -1 ;
227222 }
223+ res [0 ] = ch + ctype -> lower ;
228224 return 1 ;
229225}
230226
@@ -237,23 +233,20 @@ int PyUnicode_ToTitle(Py_UCS4 ch, Py_UCS4 *res, int size)
237233 int n = ctype -> title >> 24 ;
238234 int i ;
239235 for (i = 0 ; i < n ; i ++ ) {
240- if (res != NULL ) {
241- if (i >= size ) {
242- PyErr_SetString (PyExc_ValueError , "output buffer is too small" );
243- return -1 ;
244- }
245- res [i ] = _PyUnicode_ExtendedCase [index + i ];
236+ if (i >= size ) {
237+ PyErr_SetString (PyExc_ValueError , "output buffer is too small" );
238+ return -1 ;
246239 }
240+ res [i ] = _PyUnicode_ExtendedCase [index + i ];
247241 }
248242 return n ;
249243 }
250- if (res != NULL ) {
251- if (0 >= size ) {
252- PyErr_SetString (PyExc_ValueError , "output buffer is too small" );
253- return -1 ;
254- }
255- res [0 ] = ch + ctype -> title ;
244+
245+ if (0 >= size ) {
246+ PyErr_SetString (PyExc_ValueError , "output buffer is too small" );
247+ return -1 ;
256248 }
249+ res [0 ] = ch + ctype -> title ;
257250 return 1 ;
258251}
259252
@@ -266,23 +259,20 @@ int PyUnicode_ToUpper(Py_UCS4 ch, Py_UCS4 *res, int size)
266259 int n = ctype -> upper >> 24 ;
267260 int i ;
268261 for (i = 0 ; i < n ; i ++ ) {
269- if (res != NULL ) {
270- if (i >= size ) {
271- PyErr_SetString (PyExc_ValueError , "output buffer is too small" );
272- return -1 ;
273- }
274- res [i ] = _PyUnicode_ExtendedCase [index + i ];
262+ if (i >= size ) {
263+ PyErr_SetString (PyExc_ValueError , "output buffer is too small" );
264+ return -1 ;
275265 }
266+ res [i ] = _PyUnicode_ExtendedCase [index + i ];
276267 }
277268 return n ;
278269 }
279- if (res != NULL ) {
280- if (0 >= size ) {
281- PyErr_SetString (PyExc_ValueError , "output buffer is too small" );
282- return -1 ;
283- }
284- res [0 ] = ch + ctype -> upper ;
270+
271+ if (0 >= size ) {
272+ PyErr_SetString (PyExc_ValueError , "output buffer is too small" );
273+ return -1 ;
285274 }
275+ res [0 ] = ch + ctype -> upper ;
286276 return 1 ;
287277}
288278
@@ -295,16 +285,15 @@ int PyUnicode_ToFolded(Py_UCS4 ch, Py_UCS4 *res, int size)
295285 int n = (ctype -> lower >> 20 ) & 7 ;
296286 int i ;
297287 for (i = 0 ; i < n ; i ++ ) {
298- if (res != NULL ) {
299- if (i >= size ) {
300- PyErr_SetString (PyExc_ValueError , "output buffer is too small" );
301- return -1 ;
302- }
303- res [i ] = _PyUnicode_ExtendedCase [index + i ];
288+ if (i >= size ) {
289+ PyErr_SetString (PyExc_ValueError , "output buffer is too small" );
290+ return -1 ;
304291 }
292+ res [i ] = _PyUnicode_ExtendedCase [index + i ];
305293 }
306294 return n ;
307295 }
296+
308297 return PyUnicode_ToLower (ch , res , size );
309298}
310299
0 commit comments