Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 14a9171

Browse files
committed
Cheaper implementation of PyOS_CheckStack: only call StackSpace once and keep a sentinel in a static variable.
1 parent a1a4b59 commit 14a9171

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Mac/Python/macglue.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,13 @@ PyMac_Error(OSErr err)
410410
int
411411
PyOS_CheckStack()
412412
{
413-
long left;
413+
char here;
414+
static char *sentinel = 0;
414415

415-
left = StackSpace();
416-
if ( left < MINIMUM_STACK_SIZE )
416+
if ( sentinel == 0 ) {
417+
sentinel = &here - StackSpace() + MINIMUM_STACK_SIZE;
418+
}
419+
if ( &here < sentinel )
417420
return -1;
418421
return 0;
419422
}

0 commit comments

Comments
 (0)