summaryrefslogtreecommitdiffstats
path: root/win/tclWinInit.c
diff options
context:
space:
mode:
authorstanton <stanton>1999-05-13 01:50:17 (GMT)
committerstanton <stanton>1999-05-13 01:50:17 (GMT)
commit1fcc7feac69c4ccee7495f17ab908e53e09c4e0e (patch)
tree71c1cfb87afacabcc2a7d94434e8b9c5b18c3564 /win/tclWinInit.c
parentc1365e61e4f4bafceb9ad55d8008c4476dd3bb1b (diff)
downloadtcl-1fcc7feac69c4ccee7495f17ab908e53e09c4e0e.zip
tcl-1fcc7feac69c4ccee7495f17ab908e53e09c4e0e.tar.gz
tcl-1fcc7feac69c4ccee7495f17ab908e53e09c4e0e.tar.bz2
* win/tclWinInit.c (TclpSetVariables): Avoid calling GetUserName
if the value can be determined from the USERNAME environment variable. GetUserName is very slow.
Diffstat (limited to 'win/tclWinInit.c')
-rw-r--r--win/tclWinInit.c18
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);
}