Skip to content

Commit

Permalink
Bug 112767
Browse files Browse the repository at this point in the history
Performance: Check Profile name for ASCII before
calling the unicode converter.
r=ccarlen;/sr=brendan
  • Loading branch information
yokoyama%netscape.com committed Feb 6, 2002
1 parent 6b3e8a8 commit 9911eb9
Showing 1 changed file with 31 additions and 23 deletions.
54 changes: 31 additions & 23 deletions profile/src/nsProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,17 +770,22 @@ nsProfile::ProcessArgs(nsICmdLineService *cmdLineArgs,
if (NS_SUCCEEDED(rv))
{
if (cmdResult) {
foundProfileCommandArg = PR_TRUE;
// get a platform charset
nsAutoString charSet;
rv = GetPlatformCharset(charSet);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get a platform charset");

// convert the profile name to Unicode
foundProfileCommandArg = PR_TRUE;
nsAutoString currProfileName;
rv = ConvertStringToUnicode(charSet, cmdResult, currProfileName);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to convert ProfileName to unicode");

if (nsCRT::IsAscii(cmdResult)) {
currProfileName.AssignWithConversion(cmdResult);
}
else {
// get a platform charset
nsAutoString charSet;
rv = GetPlatformCharset(charSet);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get a platform charset");

// convert the profile name to Unicode
rv = ConvertStringToUnicode(charSet, cmdResult, currProfileName);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to convert ProfileName to unicode");
}

#ifdef DEBUG_profile
printf("ProfileName : %s\n", (const char*)cmdResult);
#endif /* DEBUG_profile */
Expand Down Expand Up @@ -833,20 +838,23 @@ nsProfile::ProcessArgs(nsICmdLineService *cmdLineArgs,
#ifdef DEBUG_profile_verbose
printf("profileName & profileDir are: %s\n", (const char*)cmdResult);
#endif

foundProfileCommandArg = PR_TRUE;

// get a platform charset
nsAutoString charSet;
rv = GetPlatformCharset(charSet);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get a platform charset");

// convert the profile name to Unicode
foundProfileCommandArg = PR_TRUE;
nsAutoString currProfileName;
nsCAutoString profileName(strtok(NS_CONST_CAST(char*,(const char*)cmdResult), " "));
rv = ConvertStringToUnicode(charSet, profileName.get(), currProfileName);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to convert ProfileName to unicode");


if (nsCRT::IsAscii(cmdResult)) {
currProfileName.AssignWithConversion(strtok(NS_CONST_CAST(char*,(const char*)cmdResult), " "));
}
else {
// get a platform charset
nsAutoString charSet;
rv = GetPlatformCharset(charSet);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get a platform charset");

// convert the profile name to Unicode
nsCAutoString profileName(strtok(NS_CONST_CAST(char*,(const char*)cmdResult), " "));
rv = ConvertStringToUnicode(charSet, profileName.get(), currProfileName);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to convert ProfileName to unicode");
}
nsAutoString currProfileDirString; currProfileDirString.AssignWithConversion(strtok(NULL, " "));

if (!currProfileDirString.IsEmpty()) {
Expand Down

0 comments on commit 9911eb9

Please sign in to comment.