mirror of https://github.com/python/cpython
Cheaper implementation of PyOS_CheckStack: only call StackSpace once and keep a sentinel in a static variable.
This commit is contained in:
parent
a1a4b5916b
commit
14a9171cff
|
@ -410,10 +410,13 @@ PyMac_Error(OSErr err)
|
||||||
int
|
int
|
||||||
PyOS_CheckStack()
|
PyOS_CheckStack()
|
||||||
{
|
{
|
||||||
long left;
|
char here;
|
||||||
|
static char *sentinel = 0;
|
||||||
|
|
||||||
left = StackSpace();
|
if ( sentinel == 0 ) {
|
||||||
if ( left < MINIMUM_STACK_SIZE )
|
sentinel = &here - StackSpace() + MINIMUM_STACK_SIZE;
|
||||||
|
}
|
||||||
|
if ( &here < sentinel )
|
||||||
return -1;
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue