@@ -207,24 +207,20 @@ int PyUnicode_ToLower(Py_UCS4 ch, Py_UCS4 *res, int size)
207
207
int n = ctype -> lower >> 24 ;
208
208
int i ;
209
209
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 ;
216
213
}
214
+ res [i ] = _PyUnicode_ExtendedCase [index + i ];
217
215
}
218
216
return n ;
219
217
}
220
218
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 ;
227
222
}
223
+ res [0 ] = ch + ctype -> lower ;
228
224
return 1 ;
229
225
}
230
226
@@ -237,23 +233,20 @@ int PyUnicode_ToTitle(Py_UCS4 ch, Py_UCS4 *res, int size)
237
233
int n = ctype -> title >> 24 ;
238
234
int i ;
239
235
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 ;
246
239
}
240
+ res [i ] = _PyUnicode_ExtendedCase [index + i ];
247
241
}
248
242
return n ;
249
243
}
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 ;
256
248
}
249
+ res [0 ] = ch + ctype -> title ;
257
250
return 1 ;
258
251
}
259
252
@@ -266,23 +259,20 @@ int PyUnicode_ToUpper(Py_UCS4 ch, Py_UCS4 *res, int size)
266
259
int n = ctype -> upper >> 24 ;
267
260
int i ;
268
261
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 ;
275
265
}
266
+ res [i ] = _PyUnicode_ExtendedCase [index + i ];
276
267
}
277
268
return n ;
278
269
}
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 ;
285
274
}
275
+ res [0 ] = ch + ctype -> upper ;
286
276
return 1 ;
287
277
}
288
278
@@ -295,16 +285,15 @@ int PyUnicode_ToFolded(Py_UCS4 ch, Py_UCS4 *res, int size)
295
285
int n = (ctype -> lower >> 20 ) & 7 ;
296
286
int i ;
297
287
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 ;
304
291
}
292
+ res [i ] = _PyUnicode_ExtendedCase [index + i ];
305
293
}
306
294
return n ;
307
295
}
296
+
308
297
return PyUnicode_ToLower (ch , res , size );
309
298
}
310
299
0 commit comments