[Python-checkins] CVS: python/dist/src/Mac/Python macimport.c,1.9,1.10

Jack Jansen jackjansen@users.sourceforge.net
2001年5月22日 07:13:04 -0700


Update of /cvsroot/python/python/dist/src/Mac/Python
In directory usw-pr-cvs1:/tmp/cvs-serv19738/Python/Mac/Python
Modified Files:
	macimport.c 
Log Message:
Fixed a nasty slowdown in imports in frozen applications: the shortcut
for loading modules from the application resource fork stopped working
when sys.path component normalization was implemented. Comparison
of sys.path components is now done by FSSpec in stead of by pathname.
Index: macimport.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Python/macimport.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** macimport.c	2001年02月21日 15:48:19	1.9
--- macimport.c	2001年05月22日 14:13:02	1.10
***************
*** 48,51 ****
--- 48,52 ----
 #endif
 #include <CodeFragments.h>
+ #include <StringCompare.h>
 
 #ifdef USE_GUSI1
***************
*** 56,59 ****
--- 57,67 ----
 #define FUNCNAME_PATTERN "init%.200s"
 
+ static int
+ fssequal(FSSpec *fs1, FSSpec *fs2)
+ {
+ 	if ( fs1->vRefNum != fs2->vRefNum || fs1->parID != fs2->parID )
+ 		return 0;
+ 	return EqualString(fs1->name, fs2->name, false, true);
+ }
 /*
 ** findnamedresource - Common code for the various *ResourceModule functions.
***************
*** 94,99 ****
 	}
 #endif /* INTERN_STRINGS */
! 
! 	if ( strcmp(filename, PyMac_ApplicationPath) == 0 ) {
 		/*
 		** Special case: the application itself. Use a shortcut to
--- 102,118 ----
 	}
 #endif /* INTERN_STRINGS */
! #ifdef USE_GUSI1
! 	if ( Path2FSSpec(filename, &fss) != noErr ) {
! #else
! 	if ( FSMakeFSSpec(0, 0, Pstring(filename), &fss) != noErr ) {
! #endif
! #ifdef INTERN_STRINGS
! 		if ( obj && max_not_a_file < MAXPATHCOMPONENTS && obj->ob_sinterned )
! 			not_a_file[max_not_a_file++] = obj;
! #endif /* INTERN_STRINGS */
! 	 	/* doesn't exist or is folder */
! 		return 0;
! 	}			
! 	if ( fssequal(&fss, &PyMac_ApplicationFSSpec) ) {
 		/*
 		** Special case: the application itself. Use a shortcut to
***************
*** 105,121 ****
 		filerh = -1;
 	} else {
- #ifdef USE_GUSI1
- 		if ( Path2FSSpec(filename, &fss) != noErr ||
- #else
- 		if ( FSMakeFSSpec(0, 0, Pstring(filename), &fss) != noErr ||
- #endif
- 		 FSpGetFInfo(&fss, &finfo) != noErr ) {
 #ifdef INTERN_STRINGS
 			if ( obj && max_not_a_file < MAXPATHCOMPONENTS && obj->ob_sinterned )
 				not_a_file[max_not_a_file++] = obj;
! #endif /* INTERN_STRINGS */
! 		 	/* doesn't exist or is folder */
 			return 0;
 		}			
 		oldrh = CurResFile();
 		filerh = FSpOpenResFile(&fss, fsRdPerm);
--- 124,135 ----
 		filerh = -1;
 	} else {
 #ifdef INTERN_STRINGS
+ 	 	if ( FSpGetFInfo(&fss, &finfo) != noErr ) {
 			if ( obj && max_not_a_file < MAXPATHCOMPONENTS && obj->ob_sinterned )
 				not_a_file[max_not_a_file++] = obj;
! 	 		/* doesn't exist or is folder */
 			return 0;
 		}			
+ #endif /* INTERN_STRINGS */
 		oldrh = CurResFile();
 		filerh = FSpOpenResFile(&fss, fsRdPerm);
***************
*** 294,298 ****
 	long num, size;
 	
! 	if ( strcmp(filename, PyMac_ApplicationPath) == 0 ) {
 		/*
 		** Special case: the application itself. Use a shortcut to
--- 308,319 ----
 	long num, size;
 	
! #ifdef USE_GUSI1
! 	if ( (err=Path2FSSpec(filename, &fss)) != noErr ||
! 	 FSpGetFInfo(&fss, &finfo) != noErr )
! #else
! 	if ( (err=FSMakeFSSpec(0, 0, Pstring(filename), &fss)) != noErr )
! #endif
! 		goto error;
! 	if ( fssequal(&fss, &PyMac_ApplicationFSSpec) ) {
 		/*
 		** Special case: the application itself. Use a shortcut to
***************
*** 304,314 ****
 		filerh = -1;
 	} else {
- #ifdef USE_GUSI1
- 		if ( (err=Path2FSSpec(filename, &fss)) != noErr ||
- 		 FSpGetFInfo(&fss, &finfo) != noErr )
- #else
- 		if ( (err=FSMakeFSSpec(0, 0, Pstring(filename), &fss)) != noErr )
- #endif
- 			goto error;
 		if ( (err=FSpGetFInfo(&fss, &finfo)) != noErr )
 			goto error;
--- 325,328 ----

AltStyle によって変換されたページ (->オリジナル) /