diff options
author | stanton <stanton@noemail.net> | 1999-05-13 01:50:16 (GMT) |
---|---|---|
committer | stanton <stanton@noemail.net> | 1999-05-13 01:50:16 (GMT) |
commit | 915d85ed4b6e000558094996ad477257634ce45c (patch) | |
tree | 71c1cfb87afacabcc2a7d94434e8b9c5b18c3564 | |
parent | ec1d50bbb5216554be2b9b099fde224079ee1565 (diff) | |
download | tcl-915d85ed4b6e000558094996ad477257634ce45c.zip tcl-915d85ed4b6e000558094996ad477257634ce45c.tar.gz tcl-915d85ed4b6e000558094996ad477257634ce45c.tar.bz2 |
* win/tclWinInit.c (TclpSetVariables): Avoid calling GetUserName
if the value can be determined from the USERNAME environment
variable. GetUserName is very slow.
FossilOrigin-Name: 62befb311d5815e8ec74056bc70899adbe2cac7c
-rw-r--r-- | win/tclWinInit.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/win/tclWinInit.c b/win/tclWinInit.c index 4d5b908..a471257 100644 --- a/win/tclWinInit.c +++ b/win/tclWinInit.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinInit.c,v 1.16 1999/04/23 01:57:32 stanton Exp $ + * RCS: @(#) $Id: tclWinInit.c,v 1.17 1999/05/13 01:50:17 stanton Exp $ */ #include "tclWinInt.h" @@ -618,13 +618,19 @@ TclpSetVariables(interp) } } + /* + * Initialize the user name from the environment first, since this is much + * faster than asking the system. + */ + Tcl_DStringSetLength(&ds, 100); - if (GetUserName(Tcl_DStringValue(&ds), &Tcl_DStringLength(&ds)) != 0) { - Tcl_SetVar2(interp, "tcl_platform", "user", Tcl_DStringValue(&ds), - TCL_GLOBAL_ONLY); - } else { - Tcl_SetVar2(interp, "tcl_platform", "user", "", TCL_GLOBAL_ONLY); + if (TclGetEnv("USERNAME", &ds) == NULL) { + if (GetUserName(Tcl_DStringValue(&ds), &Tcl_DStringLength(&ds)) == 0) { + Tcl_DStringSetLength(&ds, 0); + } } + Tcl_SetVar2(interp, "tcl_platform", "user", Tcl_DStringValue(&ds), + TCL_GLOBAL_ONLY); Tcl_DStringFree(&ds); } |