summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/VBox/Runtime/VBox/log-vbox.cpp2
-rw-r--r--src/VBox/Runtime/common/string/strprintf.cpp62
2 files changed, 43 insertions, 21 deletions
diff --git a/src/VBox/Runtime/VBox/log-vbox.cpp b/src/VBox/Runtime/VBox/log-vbox.cpp
index f1c0031aaa8..82f1184e548 100644
--- a/src/VBox/Runtime/VBox/log-vbox.cpp
+++ b/src/VBox/Runtime/VBox/log-vbox.cpp
@@ -732,6 +732,8 @@ RTDECL(PRTLOGGER) RTLogDefaultInit(void)
RTLogFlags(pLogger, "enabled unbuffered pid tid");
# ifndef IN_GUEST
pLogger->fDestFlags |= RTLOGDEST_DEBUGGER | RTLOGDEST_STDOUT;
+# else
+ RTLogGroupSettings(pLogger, "all=~0 -default.l6.l5.l4.l3");
# endif
# endif
# if defined(DEBUG_sandervl) && !defined(IN_GUEST)
diff --git a/src/VBox/Runtime/common/string/strprintf.cpp b/src/VBox/Runtime/common/string/strprintf.cpp
index 82d8d5b3eed..f9081f4058b 100644
--- a/src/VBox/Runtime/common/string/strprintf.cpp
+++ b/src/VBox/Runtime/common/string/strprintf.cpp
@@ -66,30 +66,62 @@ static DECLCALLBACK(size_t) strbufoutput(void *pvArg, const char *pachChars, siz
static DECLCALLBACK(size_t) strbufoutput(void *pvArg, const char *pachChars, size_t cbChars)
{
PSTRBUFARG pArg = (PSTRBUFARG)pvArg;
+ char *pszCur = pArg->psz; /* We actually have to spell this out for VS2010, or it will load for each case. */
cbChars = RT_MIN(pArg->cch, cbChars);
if (cbChars)
{
- memcpy(pArg->psz, pachChars, cbChars);
pArg->cch -= cbChars;
- pArg->psz += cbChars;
+
+ /* Note! For VS2010/64 we need at least 7 case statements before it generates a jump table. */
+ switch (cbChars)
+ {
+ default:
+ memcpy(pszCur, pachChars, cbChars);
+ break;
+ case 8: pszCur[7] = pachChars[7];
+ case 7: pszCur[6] = pachChars[6];
+ case 6: pszCur[5] = pachChars[5];
+ case 5: pszCur[4] = pachChars[4];
+ case 4: pszCur[3] = pachChars[3];
+ case 3: pszCur[2] = pachChars[2];
+ case 2: pszCur[1] = pachChars[1];
+ case 1: pszCur[0] = pachChars[0];
+ case 0:
+ break;
+ }
+ pArg->psz = pszCur += cbChars;
}
- *pArg->psz = '\0';
+ *pszCur = '\0';
return cbChars;
}
-RTDECL(size_t) RTStrPrintfExV(PFNSTRFORMAT pfnFormat, void *pvArg, char *pszBuffer, size_t cchBuffer, const char *pszFormat, va_list args)
+RTDECL(size_t) RTStrPrintf(char *pszBuffer, size_t cchBuffer, const char *pszFormat, ...)
{
+ /* Explicitly inline RTStrPrintfV + RTStrPrintfExV here because this is a frequently use API. */
STRBUFARG Arg;
+ va_list args;
+ size_t cbRet;
- if (!cchBuffer)
- {
- AssertMsgFailed(("Excellent idea! Format a string with no space for the output!\n"));
- return 0;
- }
+ AssertMsgReturn(cchBuffer, ("Excellent idea! Format a string with no space for the output!\n"), 0);
+ Arg.psz = pszBuffer;
+ Arg.cch = cchBuffer - 1;
+
+ va_start(args, pszFormat);
+ cbRet = RTStrFormatV(strbufoutput, &Arg, NULL, NULL, pszFormat, args);
+ va_end(args);
+
+ return cbRet;
+}
+RT_EXPORT_SYMBOL(RTStrPrintf);
+
+RTDECL(size_t) RTStrPrintfExV(PFNSTRFORMAT pfnFormat, void *pvArg, char *pszBuffer, size_t cchBuffer, const char *pszFormat, va_list args)
+{
+ STRBUFARG Arg;
+ AssertMsgReturn(cchBuffer, ("Excellent idea! Format a string with no space for the output!\n"), 0);
Arg.psz = pszBuffer;
Arg.cch = cchBuffer - 1;
return RTStrFormatV(strbufoutput, &Arg, pfnFormat, pvArg, pszFormat, args);
@@ -115,15 +147,3 @@ RTDECL(size_t) RTStrPrintfEx(PFNSTRFORMAT pfnFormat, void *pvArg, char *pszBuffe
}
RT_EXPORT_SYMBOL(RTStrPrintfEx);
-
-RTDECL(size_t) RTStrPrintf(char *pszBuffer, size_t cchBuffer, const char *pszFormat, ...)
-{
- va_list args;
- size_t cbRet;
- va_start(args, pszFormat);
- cbRet = RTStrPrintfV(pszBuffer, cchBuffer, pszFormat, args);
- va_end(args);
- return cbRet;
-}
-RT_EXPORT_SYMBOL(RTStrPrintf);
-