@@ -228,41 +228,6 @@ template_iter(PyObject *op)
228
228
return (PyObject * )iter ;
229
229
}
230
230
231
- static PyObject *
232
- template_interpolations_copy (PyObject * interpolations ) {
233
- Py_ssize_t interpolationslen = PyTuple_GET_SIZE (interpolations );
234
- PyObject * newinterpolations = PyTuple_New (interpolationslen );
235
- if (!newinterpolations ) {
236
- return NULL ;
237
- }
238
-
239
- for (Py_ssize_t i = 0 ; i < interpolationslen ; i ++ ) {
240
- PyTuple_SET_ITEM (newinterpolations , i , Py_NewRef (PyTuple_GET_ITEM (interpolations , i )));
241
- }
242
- return newinterpolations ;
243
- }
244
-
245
- static PyObject *
246
- template_interpolations_concat (PyObject * left , PyObject * right ) {
247
- Py_ssize_t leftlen = PyTuple_GET_SIZE (left );
248
- Py_ssize_t rightlen = PyTuple_GET_SIZE (right );
249
- Py_ssize_t interpolationslen = leftlen + rightlen ;
250
-
251
- PyObject * newinterpolations = PyTuple_New (interpolationslen );
252
- if (!newinterpolations ) {
253
- return NULL ;
254
- }
255
-
256
- Py_ssize_t index = 0 ;
257
- for (Py_ssize_t i = 0 ; i < leftlen ; i ++ ) {
258
- PyTuple_SET_ITEM (newinterpolations , index ++ , Py_NewRef (PyTuple_GET_ITEM (left , i )));
259
- }
260
- for (Py_ssize_t i = 0 ; i < rightlen ; i ++ ) {
261
- PyTuple_SET_ITEM (newinterpolations , index ++ , Py_NewRef (PyTuple_GET_ITEM (right , i )));
262
- }
263
- return newinterpolations ;
264
- }
265
-
266
231
static PyObject *
267
232
template_strings_append_str (PyObject * strings , PyObject * str )
268
233
{
@@ -350,7 +315,7 @@ template_concat_templates(templateobject *self, templateobject *other)
350
315
return NULL ;
351
316
}
352
317
353
- PyObject * newinterpolations = template_interpolations_concat (self -> interpolations , other -> interpolations );
318
+ PyObject * newinterpolations = PySequence_Concat (self -> interpolations , other -> interpolations );
354
319
if (newinterpolations == NULL ) {
355
320
Py_DECREF (newstrings );
356
321
return NULL ;
@@ -370,15 +335,8 @@ template_concat_template_str(templateobject *self, PyObject *other)
370
335
return NULL ;
371
336
}
372
337
373
- PyObject * newinterpolations = template_interpolations_copy (self -> interpolations );
374
- if (newinterpolations == NULL ) {
375
- Py_DECREF (newstrings );
376
- return NULL ;
377
- }
378
-
379
- templateobject * newtemplate = template_from_strings_interpolations (Py_TYPE (self ), newstrings , newinterpolations );
338
+ templateobject * newtemplate = template_from_strings_interpolations (Py_TYPE (self ), newstrings , self -> interpolations );
380
339
Py_DECREF (newstrings );
381
- Py_DECREF (newinterpolations );
382
340
return (PyObject * ) newtemplate ;
383
341
}
384
342
@@ -390,15 +348,8 @@ template_concat_str_template(templateobject *self, PyObject *other)
390
348
return NULL ;
391
349
}
392
350
393
- PyObject * newinterpolations = template_interpolations_copy (self -> interpolations );
394
- if (newinterpolations == NULL ) {
395
- Py_DECREF (newstrings );
396
- return NULL ;
397
- }
398
-
399
- templateobject * newtemplate = template_from_strings_interpolations (Py_TYPE (self ), newstrings , newinterpolations );
351
+ templateobject * newtemplate = template_from_strings_interpolations (Py_TYPE (self ), newstrings , self -> interpolations );
400
352
Py_DECREF (newstrings );
401
- Py_DECREF (newinterpolations );
402
353
return (PyObject * ) newtemplate ;
403
354
}
404
355
0 commit comments