author | Phil Ringnalda <philringnalda@gmail.com> |
Tue, 08 Aug 2017 22:08:54 -0700 | |
changeset 373570 | 81fbe7dc05a694e4e531d163b925e2830dd143d1 |
parent 373569 | eec506d87d03103778da654b7755b93a8fad7ae9 |
child 373571 | 1f3ae725ac9d7044612941b0e469c2b4fe548ad5 |
push id | 32304 |
push user | cbook@mozilla.com |
push date | Wed, 09 Aug 2017 09:37:21 +0000 |
treeherder | mozilla-central@4c5fbf493763 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
bugs | 1386103 |
milestone | 57.0a1 |
backs out | eec506d87d03103778da654b7755b93a8fad7ae9 3f9ec011c9bd5da36b51cb09a81151db70135068 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/caps/NullPrincipalURI.cpp +++ b/caps/NullPrincipalURI.cpp @@ -14,38 +14,40 @@ #include "nsEscape.h" #include "nsCRT.h" #include "nsIUUIDGenerator.h" //////////////////////////////////////////////////////////////////////////////// //// NullPrincipalURI NullPrincipalURI::NullPrincipalURI() + : mPath(mPathBytes, ArrayLength(mPathBytes), ArrayLength(mPathBytes) - 1) { } NullPrincipalURI::NullPrincipalURI(const NullPrincipalURI& aOther) + : mPath(mPathBytes, ArrayLength(mPathBytes), ArrayLength(mPathBytes) - 1) { mPath.Assign(aOther.mPath); } nsresult NullPrincipalURI::Init() { // FIXME: bug 327161 -- make sure the uuid generator is reseeding-resistant. nsCOMPtr<nsIUUIDGenerator> uuidgen = services::GetUUIDGenerator(); NS_ENSURE_TRUE(uuidgen, NS_ERROR_NOT_AVAILABLE); nsID id; nsresult rv = uuidgen->GenerateUUIDInPlace(&id); NS_ENSURE_SUCCESS(rv, rv); - mPath.SetLength(NSID_LENGTH - 1); // -1 because NSID_LENGTH counts the '\0' - id.ToProvidedString( - *reinterpret_cast<char(*)[NSID_LENGTH]>(mPath.BeginWriting())); + MOZ_ASSERT(mPathBytes == mPath.BeginWriting()); + + id.ToProvidedString(mPathBytes); MOZ_ASSERT(mPath.Length() == NSID_LENGTH - 1); MOZ_ASSERT(strlen(mPath.get()) == NSID_LENGTH - 1); return NS_OK; } /* static */
--- a/caps/NullPrincipalURI.h +++ b/caps/NullPrincipalURI.h @@ -47,12 +47,13 @@ public: private: NullPrincipalURI(const NullPrincipalURI& aOther); ~NullPrincipalURI() {} nsresult Init(); - nsAutoCStringN<NSID_LENGTH> mPath; + char mPathBytes[NSID_LENGTH]; + nsFixedCString mPath; }; #endif // __NullPrincipalURI_h__
--- a/dom/indexedDB/ProfilerHelpers.h +++ b/dom/indexedDB/ProfilerHelpers.h @@ -32,17 +32,17 @@ // Include this last to avoid path problems on Windows. #include "ActorsChild.h" namespace mozilla { namespace dom { namespace indexedDB { class MOZ_STACK_CLASS LoggingIdString final - : public nsAutoCStringN<NSID_LENGTH> + : public nsAutoCString { public: LoggingIdString() { using mozilla::ipc::BackgroundChildImpl; if (IndexedDatabaseManager::GetLoggingMode() != IndexedDatabaseManager::Logging_Disabled) { @@ -56,20 +56,19 @@ public: } } } explicit LoggingIdString(const nsID& aID) { static_assert(NSID_LENGTH > 1, "NSID_LENGTH is set incorrectly!"); - static_assert(NSID_LENGTH <= kStorageSize, - "nsID string won't fit in our storage!"); - // Capacity() excludes the null terminator; NSID_LENGTH includes it. - MOZ_ASSERT(Capacity() + 1 == NSID_LENGTH); + static_assert(NSID_LENGTH <= kDefaultStorageSize, + "nID string won't fit in our storage!"); + MOZ_ASSERT(Capacity() > NSID_LENGTH); if (IndexedDatabaseManager::GetLoggingMode() != IndexedDatabaseManager::Logging_Disabled) { // NSID_LENGTH counts the null terminator, SetLength() does not. SetLength(NSID_LENGTH - 1); aID.ToProvidedString( *reinterpret_cast<char(*)[NSID_LENGTH]>(BeginWriting()));
--- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -1973,19 +1973,22 @@ ContentParent::LaunchSubprocess(ProcessP std::vector<std::string> extraArgs; extraArgs.push_back("-childID"); char idStr[21]; SprintfLiteral(idStr, "%" PRId64, static_cast<uint64_t>(mChildID)); extraArgs.push_back(idStr); extraArgs.push_back(IsForBrowser() ? "-isForBrowser" : "-notForBrowser"); - nsAutoCStringN<1024> boolPrefs; - nsAutoCStringN<1024> intPrefs; - nsAutoCStringN<1024> stringPrefs; + char boolBuf[1024]; + char intBuf[1024]; + char strBuf[1024]; + nsFixedCString boolPrefs(boolBuf, 1024, 0); + nsFixedCString intPrefs(intBuf, 1024, 0); + nsFixedCString stringPrefs(strBuf, 1024, 0); size_t prefsLen; ContentPrefs::GetContentPrefs(&prefsLen); for (unsigned int i = 0; i < prefsLen; i++) { MOZ_ASSERT(i == 0 || strcmp(ContentPrefs::GetContentPref(i), ContentPrefs::GetContentPref(i - 1)) > 0); switch (Preferences::GetType(ContentPrefs::GetContentPref(i))) { case nsIPrefBranch::PREF_INT:
--- a/dom/xul/templates/nsXULContentBuilder.cpp +++ b/dom/xul/templates/nsXULContentBuilder.cpp @@ -595,17 +595,18 @@ nsXULContentBuilder::BuildContentFromTem } else if (tag == nsGkAtoms::textnode && nameSpaceID == kNameSpaceID_XUL) { // <xul:text value="..."> is replaced by text of the // actual value of the 'rdf:resource' attribute for the // given node. // SynchronizeUsingTemplate contains code used to update textnodes, // so make sure to modify both when changing this - nsAutoString attrValue; + char16_t attrbuf[128]; + nsFixedString attrValue(attrbuf, ArrayLength(attrbuf), 0); tmplKid->GetAttr(kNameSpaceID_None, nsGkAtoms::value, attrValue); if (!attrValue.IsEmpty()) { nsAutoString value; rv = SubstituteText(aChild, attrValue, value); if (NS_FAILED(rv)) return rv; RefPtr<nsTextNode> content = new nsTextNode(mRoot->NodeInfo()->NodeInfoManager()); @@ -731,17 +732,21 @@ nsXULContentBuilder::CopyAttributesToEle const nsAttrName* name = aTemplateNode->GetAttrNameAt(attr); int32_t attribNameSpaceID = name->NamespaceID(); // Hold a strong reference here so that the atom doesn't go away // during UnsetAttr. nsCOMPtr<nsIAtom> attribName = name->LocalName(); // XXXndeakin ignore namespaces until bug 321182 is fixed if (attribName != nsGkAtoms::id && attribName != nsGkAtoms::uri) { - nsAutoString attribValue; + // Create a buffer here, because there's a chance that an + // attribute in the template is going to be an RDF URI, which is + // usually longish. + char16_t attrbuf[128]; + nsFixedString attribValue(attrbuf, ArrayLength(attrbuf), 0); aTemplateNode->GetAttr(attribNameSpaceID, attribName, attribValue); if (!attribValue.IsEmpty()) { nsAutoString value; rv = SubstituteText(aResult, attribValue, value); if (NS_FAILED(rv)) return rv; // if the string is empty after substitutions, remove the @@ -868,17 +873,18 @@ nsXULContentBuilder::SynchronizeUsingTem nsIContent *realKid = aRealElement->GetChildAt(loop); if (! realKid) break; // check for text nodes and update them accordingly. // This code is similar to that in BuildContentFromTemplate if (tmplKid->NodeInfo()->Equals(nsGkAtoms::textnode, kNameSpaceID_XUL)) { - nsAutoString attrValue; + char16_t attrbuf[128]; + nsFixedString attrValue(attrbuf, ArrayLength(attrbuf), 0); tmplKid->GetAttr(kNameSpaceID_None, nsGkAtoms::value, attrValue); if (!attrValue.IsEmpty()) { nsAutoString value; rv = SubstituteText(aResult, attrValue, value); if (NS_FAILED(rv)) return rv; realKid->SetText(value, true); } }
--- a/dom/xul/templates/nsXULContentUtils.cpp +++ b/dom/xul/templates/nsXULContentUtils.cpp @@ -250,17 +250,18 @@ nsXULContentUtils::GetResource(int32_t a // XXX should we allow nodes with no namespace??? //NS_PRECONDITION(aNameSpaceID != kNameSpaceID_Unknown, "no namespace"); //if (aNameSpaceID == kNameSpaceID_Unknown) // return NS_ERROR_UNEXPECTED; nsresult rv; - nsAutoStringN<256> uri; + char16_t buf[256]; + nsFixedString uri(buf, ArrayLength(buf), 0); if (aNameSpaceID != kNameSpaceID_Unknown && aNameSpaceID != kNameSpaceID_None) { rv = nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNameSpaceID, uri); // XXX ignore failure; treat as "no namespace" } // XXX check to see if we need to insert a '/' or a '#'. Oy. if (!uri.IsEmpty() && uri.Last() != '#' && uri.Last() != '/' && aAttribute.First() != '#') uri.Append(char16_t('#'));
--- a/rdf/base/nsRDFContainer.cpp +++ b/rdf/base/nsRDFContainer.cpp @@ -682,17 +682,18 @@ RDFContainerImpl::GetNextValue(nsIRDFRes break; nextVal *= 10; nextVal += *p - '0'; } } static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI; - nsAutoCStringN<sizeof(kRDFNameSpaceURI) + 16> nextValStr; + char buf[sizeof(kRDFNameSpaceURI) + 16]; + nsFixedCString nextValStr(buf, sizeof(buf), 0); nextValStr = kRDFNameSpaceURI; nextValStr.Append('_'); nextValStr.AppendInt(nextVal, 10); rv = gRDFService->GetResource(nextValStr, aResult); if (NS_FAILED(rv)) return rv; // Now increment the RDF:nextVal property.
--- a/security/manager/ssl/nsNSSCertificate.h +++ b/security/manager/ssl/nsNSSCertificate.h @@ -15,16 +15,17 @@ #include "nsISimpleEnumerator.h" #include "nsIX509Cert.h" #include "nsIX509CertDB.h" #include "nsIX509CertList.h" #include "nsNSSShutDown.h" namespace mozilla { namespace pkix { class DERArray; } } +class nsAutoString; class nsINSSComponent; class nsIASN1Sequence; class nsNSSCertificate final : public nsIX509Cert, public nsISerializable, public nsIClassInfo, public nsNSSShutDownObject {
--- a/storage/mozStorageSQLFunctions.cpp +++ b/storage/mozStorageSQLFunctions.cpp @@ -160,18 +160,18 @@ levenshteinDistance(const nsAString &aSt // Note that the row width is sLen + 1 and the column height is tLen + 1, // where sLen is the length of the string "s" and tLen is the length of "t". // The first row and the first column are initialized as shown, and // the algorithm computes the remaining cells row-by-row, and // left-to-right within each row. The computation only requires that // we be able to see the current row and the previous one. // Allocate memory for two rows. - AutoTArray<int, nsAutoString::kStorageSize> row1; - AutoTArray<int, nsAutoString::kStorageSize> row2; + AutoTArray<int, nsAutoString::kDefaultStorageSize> row1; + AutoTArray<int, nsAutoString::kDefaultStorageSize> row2; // Declare the raw pointers that will actually be used to access the memory. int *prevRow = row1.AppendElements(sLen + 1); int *currRow = row2.AppendElements(sLen + 1); // Initialize the first row. for (uint32_t i = 0; i <= sLen; i++) prevRow[i] = i;
--- a/xpcom/string/nsPrintfCString.h +++ b/xpcom/string/nsPrintfCString.h @@ -15,23 +15,28 @@ * * NS_WARNING(nsPrintfCString("Unexpected value: %f", 13.917).get()); * * nsPrintfCString has a small built-in auto-buffer. For larger strings, it * will allocate on the heap. * * See also nsCString::AppendPrintf(). */ -class nsPrintfCString : public nsAutoCStringN<16> +class nsPrintfCString : public nsFixedCString { typedef nsCString string_type; public: explicit nsPrintfCString(const char_type* aFormat, ...) MOZ_FORMAT_PRINTF(2, 3) + : nsFixedCString(mLocalBuffer, kLocalBufferSize, 0) { va_list ap; va_start(ap, aFormat); AppendPrintf(aFormat, ap); va_end(ap); } + +private: + static const uint32_t kLocalBufferSize = 16; + char_type mLocalBuffer[kLocalBufferSize]; }; #endif // !defined(nsPrintfCString_h___)
--- a/xpcom/string/nsStringFwd.h +++ b/xpcom/string/nsStringFwd.h @@ -19,37 +19,33 @@ namespace mozilla { namespace detail { class nsStringRepr; class nsCStringRepr; } // namespace detail } // namespace mozilla -static const size_t AutoStringDefaultStorageSize = 64; - // Double-byte (char16_t) string types. class nsAString; class nsSubstringTuple; class nsString; -template<size_t N> class nsAutoStringN; -using nsAutoString = nsAutoStringN<AutoStringDefaultStorageSize>; +class nsAutoString; class nsDependentString; class nsDependentSubstring; class nsPromiseFlatString; class nsStringComparator; class nsDefaultStringComparator; class nsXPIDLString; // Single-byte (char) string types. class nsACString; class nsCSubstringTuple; class nsCString; -template<size_t N> class nsAutoCStringN; -using nsAutoCString = nsAutoCStringN<AutoStringDefaultStorageSize>; +class nsAutoCString; class nsDependentCString; class nsDependentCSubstring; class nsPromiseFlatCString; class nsCStringComparator; class nsDefaultCStringComparator; class nsXPIDLCString; #endif /* !defined(nsStringFwd_h___) */
--- a/xpcom/string/nsTString.h +++ b/xpcom/string/nsTString.h @@ -546,75 +546,73 @@ protected: * nsTAutoString_CharT * * Subclass of nsTString_CharT that adds support for stack-based string * allocation. It is normally not a good idea to use this class on the * heap, because it will allocate space which may be wasted if the string * it contains is significantly smaller or any larger than 64 characters. * * NAMES: - * nsAutoStringN / nsAutoString for wide characters - * nsAutoCStringN / nsAutoCString for narrow characters + * nsAutoString for wide characters + * nsAutoCString for narrow characters */ -template<size_t N> -class MOZ_NON_MEMMOVABLE nsTAutoStringN_CharT : public nsTFixedString_CharT +class MOZ_NON_MEMMOVABLE nsTAutoString_CharT : public nsTFixedString_CharT { public: - typedef nsTAutoStringN_CharT<N> self_type; + typedef nsTAutoString_CharT self_type; public: /** * constructors */ - nsTAutoStringN_CharT() - : fixed_string_type(mStorage, N, 0) + nsTAutoString_CharT() + : fixed_string_type(mStorage, kDefaultStorageSize, 0) { } explicit - nsTAutoStringN_CharT(char_type aChar) - : fixed_string_type(mStorage, N, 0) + nsTAutoString_CharT(char_type aChar) + : fixed_string_type(mStorage, kDefaultStorageSize, 0) { Assign(aChar); } explicit - nsTAutoStringN_CharT(const char_type* aData, - size_type aLength = size_type(-1)) - : fixed_string_type(mStorage, N, 0) + nsTAutoString_CharT(const char_type* aData, size_type aLength = size_type(-1)) + : fixed_string_type(mStorage, kDefaultStorageSize, 0) { Assign(aData, aLength); } #if defined(CharT_is_PRUnichar) && defined(MOZ_USE_CHAR16_WRAPPER) explicit - nsTAutoStringN_CharT(char16ptr_t aData, size_type aLength = size_type(-1)) - : nsTAutoStringN_CharT(static_cast<const char16_t*>(aData), aLength) + nsTAutoString_CharT(char16ptr_t aData, size_type aLength = size_type(-1)) + : nsTAutoString_CharT(static_cast<const char16_t*>(aData), aLength) { } #endif - nsTAutoStringN_CharT(const self_type& aStr) - : fixed_string_type(mStorage, N, 0) + nsTAutoString_CharT(const self_type& aStr) + : fixed_string_type(mStorage, kDefaultStorageSize, 0) { Assign(aStr); } explicit - nsTAutoStringN_CharT(const substring_type& aStr) - : fixed_string_type(mStorage, N, 0) + nsTAutoString_CharT(const substring_type& aStr) + : fixed_string_type(mStorage, kDefaultStorageSize, 0) { Assign(aStr); } - MOZ_IMPLICIT nsTAutoStringN_CharT(const substring_tuple_type& aTuple) - : fixed_string_type(mStorage, N, 0) + MOZ_IMPLICIT nsTAutoString_CharT(const substring_tuple_type& aTuple) + : fixed_string_type(mStorage, kDefaultStorageSize, 0) { Assign(aTuple); } // |operator=| does not inherit, so we must define our own self_type& operator=(char_type aChar) { Assign(aChar); @@ -643,26 +641,26 @@ public: return *this; } self_type& operator=(const substring_tuple_type& aTuple) { Assign(aTuple); return *this; } - static const size_t kStorageSize = N; + enum + { + kDefaultStorageSize = 64 + }; private: - char_type mStorage[N]; + char_type mStorage[kDefaultStorageSize]; }; -// We define this typedef instead of providing a default value for N so that so -// there is a default typename that doesn't require angle brackets. -using nsTAutoString_CharT = nsTAutoStringN_CharT<AutoStringDefaultStorageSize>; // // nsAutoString stores pointers into itself which are invalidated when an // nsTArray is resized, so nsTArray must not be instantiated with nsAutoString // elements! // template<class E> class nsTArrayElementTraits; template<>
--- a/xpcom/string/string-template-def-char.h +++ b/xpcom/string/string-template-def-char.h @@ -6,17 +6,16 @@ // IWYU pragma: private, include "nsString.h" #define CharT char #define CharT_is_char 1 #define nsTAString_IncompatibleCharT nsAString #define nsTString_CharT nsCString #define nsTStringRepr_CharT nsCStringRepr #define nsTFixedString_CharT nsFixedCString -#define nsTAutoStringN_CharT nsAutoCStringN #define nsTAutoString_CharT nsAutoCString #define nsTSubstring_CharT nsACString #define PrintfAppend_CharT PrintfAppend_nsACString #define nsTSubstringTuple_CharT nsCSubstringTuple #define nsTStringComparator_CharT nsCStringComparator #define nsTDefaultStringComparator_CharT nsDefaultCStringComparator #define nsTDependentString_CharT nsDependentCString #define nsTDependentSubstring_CharT nsDependentCSubstring
--- a/xpcom/string/string-template-def-unichar.h +++ b/xpcom/string/string-template-def-unichar.h @@ -6,17 +6,16 @@ // IWYU pragma: private, include "nsString.h" #define CharT char16_t #define CharT_is_PRUnichar 1 #define nsTAString_IncompatibleCharT nsACString #define nsTString_CharT nsString #define nsTStringRepr_CharT nsStringRepr #define nsTFixedString_CharT nsFixedString -#define nsTAutoStringN_CharT nsAutoStringN #define nsTAutoString_CharT nsAutoString #define nsTSubstring_CharT nsAString #define PrintfAppend_CharT PrintfAppend_nsAString #define nsTSubstringTuple_CharT nsSubstringTuple #define nsTStringComparator_CharT nsStringComparator #define nsTDefaultStringComparator_CharT nsDefaultStringComparator #define nsTDependentString_CharT nsDependentString #define nsTDependentSubstring_CharT nsDependentSubstring
--- a/xpcom/string/string-template-undef.h +++ b/xpcom/string/string-template-undef.h @@ -7,17 +7,16 @@ #undef CharT #undef CharT_is_PRUnichar #undef CharT_is_char #undef nsTAString_IncompatibleCharT #undef nsTString_CharT #undef nsTStringRepr_CharT #undef nsTFixedString_CharT -#undef nsTAutoStringN_CharT #undef nsTAutoString_CharT #undef nsTSubstring_CharT #undef PrintfAppend_CharT #undef nsTSubstringTuple_CharT #undef nsTStringComparator_CharT #undef nsTDefaultStringComparator_CharT #undef nsTDependentString_CharT #undef nsTDependentSubstring_CharT