Skip to content

Commit d7c57a0

Browse files
committed
improve interpreter creation speed, if there is no zipfs tcl-library (avoid performance penalty [62019f8aa9f5ec73])
1 parent cb3067d commit d7c57a0

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

generic/tclZipfs.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ static const char pwrot[17] =
398398
"\x00\x80\x40\xC0\x20\xA0\x60\xE0"
399399
"\x10\x90\x50\xD0\x30\xB0\x70\xF0";
400400

401+
static int zipfs_tcl_library_init = 0;
401402
static const char *zipfs_literal_tcl_library = NULL;
402403

403404
/* Function prototypes */
@@ -4340,6 +4341,7 @@ ScriptLibrarySetup(
43404341
Tcl_DecrRefCount(searchPathObj);
43414342
/* Bug [fccb9f322f]. Reinit system encoding after setting search path */
43424343
TclpSetInitialEncodings();
4344+
zipfs_tcl_library_init = 1;
43434345
return libDirObj;
43444346
}
43454347

@@ -4357,10 +4359,13 @@ TclZipfs_TclLibrary(void)
43574359

43584360
/*
43594361
* Use the cached value if that has been set; we don't want to repeat the
4360-
* searching and mounting.
4362+
* searching and mounting. Even if it is not found, see [62019f8aa9f5ec73].
43614363
*/
4362-
4363-
if (zipfs_literal_tcl_library) {
4364+
4365+
if (zipfs_tcl_library_init) {
4366+
if (!zipfs_literal_tcl_library) {
4367+
return NULL;
4368+
}
43644369
return ScriptLibrarySetup(zipfs_literal_tcl_library);
43654370
}
43664371

@@ -4417,6 +4422,11 @@ TclZipfs_TclLibrary(void)
44174422
if (zipfs_literal_tcl_library) {
44184423
return ScriptLibrarySetup(zipfs_literal_tcl_library);
44194424
}
4425+
/*
4426+
* No zipfs tcl-library, mark it to avoid performance penalty [62019f8aa9f5ec73],
4427+
* by future calls (child interpreters, threads, etc).
4428+
*/
4429+
zipfs_tcl_library_init = 1;
44204430
return NULL;
44214431
}
44224432

0 commit comments

Comments
 (0)