]> granicus.if.org Git - python/commitdiff
When a recycled frame has more local+stack slots than needed,
authorGuido van Rossum <guido@python.org>
Fri, 24 Jan 1997 04:00:21 +0000 (04:00 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 24 Jan 1997 04:00:21 +0000 (04:00 +0000)
give the extra slots to the stack rather than than forgetting about
them (this reduces the number of reallocs done).

Objects/frameobject.c

index 79757e9583aa274b490f9a3a6190822ac61cc099..ae962e995869807e8d369e3471b2454324e50d9e 100644 (file)
@@ -172,6 +172,8 @@ newframeobject(back, code, globals, locals)
                        if (f == NULL)
                                return (PyFrameObject *)err_nomem();
                }
+               else
+                       extras = f->f_nlocals + f->f_stacksize;
                f->ob_type = &Frametype;
                NEWREF(f);
        }
@@ -203,11 +205,11 @@ newframeobject(back, code, globals, locals)
        f->f_trace = NULL;
 
        f->f_lasti = 0;
-       f->f_lineno = -1;
+       f->f_lineno = code->co_firstlineno;
        f->f_restricted = (builtins != getbuiltindict());
        f->f_iblock = 0;
        f->f_nlocals = code->co_nlocals;
-       f->f_stacksize = code->co_stacksize;
+       f->f_stacksize = extras - code->co_nlocals;
 
        while (--extras >= 0)
                f->f_localsplus[extras] = NULL;