mirror of https://github.com/python/cpython
When loading a PYC resource check whether the filename is the
application, and if so take a shortcut. This should speedup loading PYC resources when running off a CDROM quite a bit.
This commit is contained in:
parent
6c06590305
commit
8096daad4f
|
@ -579,6 +579,16 @@ char *filename;
|
|||
int ok;
|
||||
Handle h;
|
||||
|
||||
if ( strcmp(filename, PyMac_ApplicationPath) == 0 ) {
|
||||
/*
|
||||
** Special case: the application itself. Use a shortcut to
|
||||
** forestall opening and closing the application numerous times
|
||||
** (which is dead slow when running from CDROM)
|
||||
*/
|
||||
oldrh = CurResFile();
|
||||
UseResFile(PyMac_AppRefNum);
|
||||
filerh = -1;
|
||||
} else {
|
||||
if ( FSMakeFSSpec(0, 0, Pstring(filename), &fss) != noErr )
|
||||
return 0; /* It doesn't exist */
|
||||
if ( FSpGetFInfo(&fss, &finfo) != noErr )
|
||||
|
@ -588,10 +598,12 @@ char *filename;
|
|||
if ( filerh == -1 )
|
||||
return 0;
|
||||
UseResFile(filerh);
|
||||
}
|
||||
SetResLoad(0);
|
||||
h = Get1NamedResource('PYC ', Pstring(module));
|
||||
SetResLoad(1);
|
||||
ok = (h != NULL);
|
||||
if ( filerh != -1 )
|
||||
CloseResFile(filerh);
|
||||
UseResFile(oldrh);
|
||||
return ok;
|
||||
|
@ -613,6 +625,16 @@ char *filename;
|
|||
PyObject *m, *co;
|
||||
long num, size;
|
||||
|
||||
if ( strcmp(filename, PyMac_ApplicationPath) == 0 ) {
|
||||
/*
|
||||
** Special case: the application itself. Use a shortcut to
|
||||
** forestall opening and closing the application numerous times
|
||||
** (which is dead slow when running from CDROM)
|
||||
*/
|
||||
oldrh = CurResFile();
|
||||
UseResFile(PyMac_AppRefNum);
|
||||
filerh = -1;
|
||||
} else {
|
||||
if ( (err=FSMakeFSSpec(0, 0, Pstring(filename), &fss)) != noErr )
|
||||
goto error;
|
||||
if ( (err=FSpGetFInfo(&fss, &finfo)) != noErr )
|
||||
|
@ -624,6 +646,7 @@ char *filename;
|
|||
goto error;
|
||||
}
|
||||
UseResFile(filerh);
|
||||
}
|
||||
h = Get1NamedResource('PYC ', Pstring(module));
|
||||
if ( h == NULL ) {
|
||||
err = ResError();
|
||||
|
@ -651,6 +674,7 @@ char *filename;
|
|||
}
|
||||
}
|
||||
HUnlock(h);
|
||||
if ( filerh != -1 )
|
||||
CloseResFile(filerh);
|
||||
UseResFile(oldrh);
|
||||
if ( co ) {
|
||||
|
|
Loading…
Reference in New Issue