Add cache for codepage so it does not call hole time on csrss when it wring out text
it will incress the speed.  Thx w3seek and kjk for the idea.
Modified: trunk/reactos/subsys/system/cmd/chcp.c
Modified: trunk/reactos/subsys/system/cmd/cmd.c
Modified: trunk/reactos/subsys/system/cmd/cmd.h
Modified: trunk/reactos/subsys/system/cmd/console.c
Modified: trunk/reactos/subsys/system/cmd/start.c

Modified: trunk/reactos/subsys/system/cmd/chcp.c
--- trunk/reactos/subsys/system/cmd/chcp.c	2005-05-07 08:32:28 UTC (rev 15075)
+++ trunk/reactos/subsys/system/cmd/chcp.c	2005-05-07 11:14:58 UTC (rev 15076)
@@ -14,6 +14,8 @@
 #include "precomp.h"
 #include "resource.h"
 
+
+
 #ifdef INCLUDE_CMD_CHCP
 
 INT CommandChcp (LPTSTR cmd, LPTSTR param)
@@ -39,7 +41,7 @@
 	{
 		/* display active code page number */
 		LoadString(GetModuleHandle(NULL), STRING_CHCP_ERROR1, szMsg, RC_STRING_MAX_SIZE);
-		ConErrPrintf(szMsg, GetConsoleCP());
+		ConErrPrintf(szMsg, GetCodePage);
 		return 0;
 	}
 
@@ -53,7 +55,7 @@
 
 
 	/* save old code page */
-	uOldCodePage = GetConsoleCP();
+	uOldCodePage = GetCodePage;
 
 	uNewCodePage = (UINT)_ttoi(arg[0]);
 
@@ -72,8 +74,10 @@
 	}
 	else
 	{
+		
 		SetConsoleOutputCP (uNewCodePage);
 		InitLocale ();
+		GetCodePage = GetConsoleCP();
 	}
 
 	freep (arg);

Modified: trunk/reactos/subsys/system/cmd/cmd.c
--- trunk/reactos/subsys/system/cmd/cmd.c	2005-05-07 08:32:28 UTC (rev 15075)
+++ trunk/reactos/subsys/system/cmd/cmd.c	2005-05-07 11:14:58 UTC (rev 15076)
@@ -426,6 +426,9 @@
 				ENABLE_PROCESSED_INPUT );
 	}
 
+	/* Get code page if it has been change */
+	GetCodePage = GetConsoleCP();
+    OutCodePage = GetConsoleOutputCP();
 #ifndef __REACTOS__
 	SetConsoleTitle (szWindowTitle);
 #endif
@@ -1416,6 +1419,8 @@
 #endif
 
   SetFileApisToOEM();
+  GetCodePage = 0;
+  OutCodePage = 0;
 
   hConsole = CreateFile(_T("CONOUT$"), GENERIC_READ|GENERIC_WRITE,
                         FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
@@ -1428,6 +1433,9 @@
   wColor = Info.wAttributes;
   wDefColor = wColor;
 
+  GetCodePage = GetConsoleCP();
+  OutCodePage = GetConsoleOutputCP();
+
   /* check switches on command-line */
   Initialize(argc, argv);
 

Modified: trunk/reactos/subsys/system/cmd/cmd.h
--- trunk/reactos/subsys/system/cmd/cmd.h	2005-05-07 08:32:28 UTC (rev 15075)
+++ trunk/reactos/subsys/system/cmd/cmd.h	2005-05-07 11:14:58 UTC (rev 15076)
@@ -292,10 +292,14 @@
 extern TCHAR cDecimalSeparator;
 extern INT nNumberGroups;
 
+
 VOID InitLocale (VOID);
 VOID PrintDate (VOID);
 VOID PrintTime (VOID);
 
+/* cache codepage */
+extern UINT GetCodePage;
+extern UINT OutCodePage;
 
 /* Prototypes for MEMORY.C */
 INT CommandMemory (LPTSTR, LPTSTR);

Modified: trunk/reactos/subsys/system/cmd/console.c
--- trunk/reactos/subsys/system/cmd/console.c	2005-05-07 08:32:28 UTC (rev 15075)
+++ trunk/reactos/subsys/system/cmd/console.c	2005-05-07 11:14:58 UTC (rev 15076)
@@ -11,12 +11,19 @@
  *        Remove all hardcode string to En.rc  
  */
 
+
+
 #include "precomp.h"
 #include "resource.h"
 
 
 #define OUTPUT_BUFFER_SIZE  4096
 
+
+UINT GetCodePage;
+UINT OutCodePage;
+
+
 VOID ConInDisable (VOID)
 {
 	HANDLE hInput = GetStdHandle (STD_INPUT_HANDLE);
@@ -104,7 +111,7 @@
 	ReadFile (hFile, (PVOID)pBuf, dwLength, &dwRead, NULL);
 
 #ifdef _UNICODE
-	MultiByteToWideChar(  GetConsoleCP(), 0, pBuf, dwLength + 1, lpInput, dwLength + 1);
+	MultiByteToWideChar(  GetCodePage, 0, pBuf, dwLength + 1, lpInput, dwLength + 1);
 #endif
 	p = lpInput;
 	for (i = 0; i < dwRead; i++, p++)
@@ -132,7 +139,7 @@
 	WCHAR ws[2];
 	ws[0] = c;
 	ws[1] = 0;
-	WideCharToMultiByte( GetConsoleOutputCP(), 0, ws, 2, as, 2, NULL, NULL);
+	WideCharToMultiByte( OutCodePage, 0, ws, 2, as, 2, NULL, NULL);
 	cc = as[0];
 #else
 	cc = c;
@@ -158,7 +165,7 @@
 	len = _tcslen(szText);
 #ifdef _UNICODE
 	pBuf = malloc(len + 1);
-	len = WideCharToMultiByte( GetConsoleOutputCP(), 0, szText, len + 1, pBuf, len + 1, NULL, NULL) - 1;
+	len = WideCharToMultiByte( OutCodePage, 0, szText, len + 1, pBuf, len + 1, NULL, NULL) - 1;
 #else
 	pBuf = szText;
 #endif
@@ -193,7 +200,7 @@
 	len = _vstprintf (szOut, szFormat, arg_ptr);
 #ifdef _UNICODE
 	pBuf = malloc(len + 1);
-	len = WideCharToMultiByte( GetConsoleOutputCP(), 0, szOut, len + 1, pBuf, len + 1, NULL, NULL) - 1;
+	len = WideCharToMultiByte( OutCodePage, 0, szOut, len + 1, pBuf, len + 1, NULL, NULL) - 1;
 #else
 	pBuf = szOut;
 #endif

Modified: trunk/reactos/subsys/system/cmd/start.c
--- trunk/reactos/subsys/system/cmd/start.c	2005-05-07 08:32:28 UTC (rev 15075)
+++ trunk/reactos/subsys/system/cmd/start.c	2005-05-07 11:14:58 UTC (rev 15076)
@@ -114,6 +114,9 @@
 			}
 			CloseHandle (prci.hThread);
 			CloseHandle (prci.hProcess);
+		/* Get New code page if it has change */
+		GetCodePage = GetConsoleCP();
+        OutCodePage = GetConsoleOutputCP();
 		}
 		else
 		{