From 36ccf5c4b99209a69bb03ab876ec534f13467c50 Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Wed, 24 Jan 2001 15:10:08 +0000 Subject: [PATCH] performance fix for mailnews for. (especially us-ascii users) skip a lot of expensive code if we don't need to do the conversion. this will help sorting, scrolling and message display. there is more work to do on this code for non us-ascii users. sr=bienvenu --- mailnews/mime/src/comi18n.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mailnews/mime/src/comi18n.cpp b/mailnews/mime/src/comi18n.cpp index ff3ede7cc7a2..674b94d2d48c 100644 --- a/mailnews/mime/src/comi18n.cpp +++ b/mailnews/mime/src/comi18n.cpp @@ -1437,6 +1437,23 @@ PRInt32 MIME_ConvertCharset(const PRBool autoDetection, const char* from_charset const char* inBuffer, const PRInt32 inLength, char** outBuffer, PRInt32* outLength, PRInt32* numUnConverted) { + if (!autoDetection && from_charset && to_charset && + (!strcasecmp(from_charset,to_charset) || + (!strcasecmp(from_charset,"us-ascii") && !strcasecmp(to_charset,"UTF-8")) || + (!strcasecmp(from_charset,"UTF-8") && !strcasecmp(to_charset,"us-ascii")))) { + if (NULL != numUnConverted) + *numUnConverted = 0; + + *outBuffer = (char *) PR_Malloc(inLength+1); + if (NULL != *outBuffer) { + nsCRT::memcpy(*outBuffer, inBuffer, inLength); + *outLength = inLength; + (*outBuffer)[inLength] = '\0'; + return 0; + } + return -1; + } + MimeCharsetConverterClass aMimeCharsetConverterClass; PRInt32 res;