Closed Bug 104763 Opened 23 years ago Closed 18 years ago

remove members of nsString that we don't want to keep

Categories

(Core :: XPCOM, defect, P3)

defect

Tracking

()

RESOLVED FIXED
Future

People

(Reporter: dbaron, Assigned: dbaron)

Details

Attachments

(3 files)

In order to move to a |typedef| replacing nsString with nsSharableString, we need to remove the members of nsString that we don't want to keep.
Comment on attachment 53526 [details] [diff] [review] remove |fputs| overloads and most uses of |ToCString| >Index: mozilla/content/base/src/nsCommentNode.cpp >=================================================================== >RCS file: /cvsroot/mozilla/content/base/src/nsCommentNode.cpp,v >retrieving revision 3.51 >diff -u -d -r3.51 nsCommentNode.cpp >--- nsCommentNode.cpp 2001/09/25 01:30:17 3.51 >+++ nsCommentNode.cpp 2001/10/15 01:49:19 >@@ -369,7 +369,7 @@ > > nsAutoString tmp; > mInner.ToCString(tmp, 0, mInner.mText.GetLength()); It looks like this ToCString on nsGenericDOMDataNode could take an nsACString& as the first parameter. Different patch, though. File on one jst I guess. >- fputs(tmp, out); >+ fputs(NS_LossyConvertUCS2toASCII(tmp).get(), out); > > fputs("-->\n", out); > return NS_OK; >Index: mozilla/intl/uconv/src/nsCharsetConverterManager.cpp >=================================================================== >RCS file: /cvsroot/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp,v >retrieving revision 1.79 >diff -u -d -r1.79 nsCharsetConverterManager.cpp >--- nsCharsetConverterManager.cpp 2001/10/10 05:00:36 1.79 >+++ nsCharsetConverterManager.cpp 2001/10/15 01:49:35 >@@ -502,15 +502,13 @@ > nsresult res = NS_OK; > > static const char kUnicodeEncoderContractIDBase[] = NS_UNICODEENCODER_CONTRACTID_BASE; >- static PRInt32 baselen = sizeof(kUnicodeEncoderContractIDBase) - 1; >- >- char contractid[256]; >- PL_strncpy(contractid, kUnicodeEncoderContractIDBase, 256); >- aDest->ToCString(contractid + baselen, 256 - baselen); >+ nsCAutoString contractid(nsDependentCString(kUnicodeEncoderContractIDBase, >+ sizeof(kUnicodeEncoderContractIDBase) - 1) + >+ NS_LossyConvertUCS2toASCII(*aDest)); On second thought, NS_LITERAL_CSTRING(NS_UNICODEENCODER_CONTRACTID_BASE) should just work. The only reason it doesn't work with NS_LITERAL_STRING is because of the L" construct, a problem NS_LITERAL_CSTRING doesn't have. >@@ -532,9 +530,9 @@ > static const char kUnicodeDecoderContractIDBase[] = NS_UNICODEDECODER_CONTRACTID_BASE; > static PRInt32 baselen = sizeof(kUnicodeDecoderContractIDBase) - 1; > >- char contractid[256]; >- PL_strncpy(contractid, kUnicodeDecoderContractIDBase, 256); >- aSrc->ToCString(contractid + baselen, 256 - baselen); >+ nsCAutoString contractid(nsDependentCString(kUnicodeDecoderContractIDBase, >+ sizeof(kUnicodeDecoderContractIDBase) - 1) + >+ NS_LossyConvertUCS2toASCII(*aSrc)); Same thing ...
Attachment #53526 - Flags: review+
Comment on attachment 53533 [details] [diff] [review] additional patch also needed >Index: mozilla/gfx/tests/TestColorNames.cpp >=================================================================== >RCS file: /cvsroot/mozilla/gfx/tests/TestColorNames.cpp,v >retrieving revision 3.10 >diff -u -d -r3.10 TestColorNames.cpp >--- TestColorNames.cpp 2001/09/26 00:16:02 3.10 >+++ TestColorNames.cpp 2001/10/15 01:49:34 >@@ -66,41 +66,40 @@ > index = eColorName_UNKNOWN; > while (PRInt32(index) < (PRInt32 (eColorName_COUNT) - 1)) { > // Lookup color by name and make sure it has the right id >- char tagName[512]; > index = nsColorName(PRInt32(index) + 1); >- nsColorNames::GetStringValue(index).ToCString(tagName, sizeof(tagName)); >+ nsCString tagName(nsColorNames::GetStringValue(index)); const nsCString& tagName = nsColorNames::GetStringValue(index); Go on, break 2.7.2.3, you know I want you to ;-)
Attachment #53533 - Flags: review+
> const nsCString& tagName = nsColorNames::GetStringValue(index); I can't, because I require a non-const string here.
Okay, r=jag then
Checked in 2001-10-15 20:52/53 PDT.
Status: NEW → ASSIGNED
Keywords: perf
Priority: -- → P3
Target Milestone: --- → Future
This was fixed a long time ago. I suspect it was kept open for attachment 54333 [details] [diff] [review], but nsString::ToCString() doesn't exist anymore, so that patch has been mooted.
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Component: String → XPCOM
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: