Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bf10973 commit b6a6bdcCopy full SHA for b6a6bdc
1 file changed
Objects/stringobject.c
@@ -246,11 +246,23 @@ stringitem(a, i)
246
stringobject *a;
247
register int i;
248
{
249
+ /* This is optimized since this is a common operation! */
250
+
251
+ register stringobject *op;
252
if (i < 0 || i >= a->ob_size) {
253
err_setstr(IndexError, "string index out of range");
254
return NULL;
255
}
- return stringslice(a, i, i+1);
256
+ op = (stringobject *)
257
+ malloc(sizeof(stringobject) + sizeof(char));
258
+ if (op == NULL)
259
+ return err_nomem();
260
+ NEWREF(op);
261
+ op->ob_type = &Stringtype;
262
+ op->ob_size = 1;
263
+ op->ob_sval[0] = a->ob_sval[i];
264
+ op->ob_sval[1] = '\0';
265
+ return (object *) op;
266
267
268
static int
0 commit comments