mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
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
1 changed files with 6 additions and 3 deletions
|
@ -410,10 +410,13 @@ PyMac_Error(OSErr err)
|
|||
int
|
||||
PyOS_CheckStack()
|
||||
{
|
||||
long left;
|
||||
char here;
|
||||
static char *sentinel = 0;
|
||||
|
||||
left = StackSpace();
|
||||
if ( left < MINIMUM_STACK_SIZE )
|
||||
if ( sentinel == 0 ) {
|
||||
sentinel = &here - StackSpace() + MINIMUM_STACK_SIZE;
|
||||
}
|
||||
if ( &here < sentinel )
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue