From ba6cb5196e9f21c62181e9ffde73d80f025b4785 Mon Sep 17 00:00:00 2001 From: Thomas Wisniewski Date: Fri, 23 Sep 2016 21:10:01 -0400 Subject: [PATCH] Bug 1305202 - Use NullString() more and remove superfluous Truncates(). r=smaug --- dom/ipc/Blob.cpp | 10 ++-------- dom/json/nsJSON.cpp | 2 -- dom/plugins/ipc/PluginMessageUtils.h | 4 +--- js/xpconnect/src/XPCConvert.cpp | 1 - parser/html/nsHtml5TreeOperation.cpp | 4 +--- storage/Variant.h | 2 -- storage/mozStorageArgValueArray.cpp | 2 -- storage/mozStorageStatement.cpp | 2 -- toolkit/components/places/nsNavBookmarks.cpp | 6 ++---- xpcom/ds/nsVariant.cpp | 1 - 10 files changed, 6 insertions(+), 28 deletions(-) diff --git a/dom/ipc/Blob.cpp b/dom/ipc/Blob.cpp index b51665e9f716..22d76c9bd6cb 100644 --- a/dom/ipc/Blob.cpp +++ b/dom/ipc/Blob.cpp @@ -3574,10 +3574,7 @@ BlobChild::SetMysteryBlobInfo(const nsString& aContentType, uint64_t aLength) MOZ_ASSERT(mBlobImpl); MOZ_ASSERT(mRemoteBlobImpl); - nsString voidString; - voidString.SetIsVoid(true); - - mBlobImpl->SetLazyData(voidString, aContentType, aLength, INT64_MAX); + mBlobImpl->SetLazyData(NullString(), aContentType, aLength, INT64_MAX); NormalBlobConstructorParams params(aContentType, aLength, @@ -4400,10 +4397,7 @@ BlobParent::RecvResolveMystery(const ResolveMysteryParams& aParams) return false; } - nsString voidString; - voidString.SetIsVoid(true); - - mBlobImpl->SetLazyData(voidString, + mBlobImpl->SetLazyData(NullString(), params.contentType(), params.length(), INT64_MAX); diff --git a/dom/json/nsJSON.cpp b/dom/json/nsJSON.cpp index a3d1f4f00f46..f46606fc5a81 100644 --- a/dom/json/nsJSON.cpp +++ b/dom/json/nsJSON.cpp @@ -70,7 +70,6 @@ nsJSON::Encode(JS::Handle aValue, JSContext* cx, uint8_t aArgc, return rv; if (aArgc == 0) { - aJSON.Truncate(); aJSON.SetIsVoid(true); return NS_OK; } @@ -83,7 +82,6 @@ nsJSON::Encode(JS::Handle aValue, JSContext* cx, uint8_t aArgc, rv = NS_OK; // if we didn't consume anything, it's not JSON, so return null if (!writer.DidWrite()) { - aJSON.Truncate(); aJSON.SetIsVoid(true); } else { writer.FlushBuffer(); diff --git a/dom/plugins/ipc/PluginMessageUtils.h b/dom/plugins/ipc/PluginMessageUtils.h index d58c38989244..0150eac10cda 100644 --- a/dom/plugins/ipc/PluginMessageUtils.h +++ b/dom/plugins/ipc/PluginMessageUtils.h @@ -253,9 +253,7 @@ inline nsCString NullableString(const char* aString) { if (!aString) { - nsCString str; - str.SetIsVoid(true); - return str; + return NullCString(); } return nsCString(aString); } diff --git a/js/xpconnect/src/XPCConvert.cpp b/js/xpconnect/src/XPCConvert.cpp index 23e1731a9d78..feea398cf543 100644 --- a/js/xpconnect/src/XPCConvert.cpp +++ b/js/xpconnect/src/XPCConvert.cpp @@ -640,7 +640,6 @@ XPCConvert::JSData2Native(void* d, HandleValue s, { if (s.isNull() || s.isUndefined()) { nsACString* rs = *((nsACString**)d); - rs->Truncate(); rs->SetIsVoid(true); return true; } diff --git a/parser/html/nsHtml5TreeOperation.cpp b/parser/html/nsHtml5TreeOperation.cpp index 3ba9ec975b8b..af246a253929 100644 --- a/parser/html/nsHtml5TreeOperation.cpp +++ b/parser/html/nsHtml5TreeOperation.cpp @@ -565,14 +565,12 @@ nsHtml5TreeOperation::AppendDoctypeToDocument(nsIAtom* aName, // Adapted from nsXMLContentSink // Create a new doctype node nsCOMPtr docType; - nsAutoString voidString; - voidString.SetIsVoid(true); NS_NewDOMDocumentType(getter_AddRefs(docType), aBuilder->GetNodeInfoManager(), aName, aPublicId, aSystemId, - voidString); + NullString()); NS_ASSERTION(docType, "Doctype creation failed."); nsCOMPtr asContent = do_QueryInterface(docType); return AppendToDocument(asContent, aBuilder); diff --git a/storage/Variant.h b/storage/Variant.h index 988851ad8084..265abb02aede 100644 --- a/storage/Variant.h +++ b/storage/Variant.h @@ -357,7 +357,6 @@ public: NS_IMETHOD GetAsAUTF8String(nsACString &_str) { // Return a void string. - _str.Truncate(0); _str.SetIsVoid(true); return NS_OK; } @@ -365,7 +364,6 @@ public: NS_IMETHOD GetAsAString(nsAString &_str) { // Return a void string. - _str.Truncate(0); _str.SetIsVoid(true); return NS_OK; } diff --git a/storage/mozStorageArgValueArray.cpp b/storage/mozStorageArgValueArray.cpp index 3b9daab2fd08..40d67a4cd897 100644 --- a/storage/mozStorageArgValueArray.cpp +++ b/storage/mozStorageArgValueArray.cpp @@ -108,7 +108,6 @@ ArgValueArray::GetUTF8String(uint32_t aIndex, if (::sqlite3_value_type(mArgv[aIndex]) == SQLITE_NULL) { // NULL columns should have IsVoid set to distinguish them from an empty // string. - _value.Truncate(0); _value.SetIsVoid(true); } else { @@ -127,7 +126,6 @@ ArgValueArray::GetString(uint32_t aIndex, if (::sqlite3_value_type(mArgv[aIndex]) == SQLITE_NULL) { // NULL columns should have IsVoid set to distinguish them from an empty // string. - _value.Truncate(0); _value.SetIsVoid(true); } else { _value.Assign(static_cast(::sqlite3_value_text16(mArgv[aIndex])), diff --git a/storage/mozStorageStatement.cpp b/storage/mozStorageStatement.cpp index 3733a7ae15b1..6f032dde54a8 100644 --- a/storage/mozStorageStatement.cpp +++ b/storage/mozStorageStatement.cpp @@ -772,7 +772,6 @@ Statement::GetUTF8String(uint32_t aIndex, if (type == mozIStorageStatement::VALUE_TYPE_NULL) { // NULL columns should have IsVoid set to distinguish them from the empty // string. - _value.Truncate(0); _value.SetIsVoid(true); } else { @@ -795,7 +794,6 @@ Statement::GetString(uint32_t aIndex, if (type == mozIStorageStatement::VALUE_TYPE_NULL) { // NULL columns should have IsVoid set to distinguish them from the empty // string. - _value.Truncate(0); _value.SetIsVoid(true); } else { const char16_t *value = diff --git a/toolkit/components/places/nsNavBookmarks.cpp b/toolkit/components/places/nsNavBookmarks.cpp index 74da2203da3c..d2459ac8da8e 100644 --- a/toolkit/components/places/nsNavBookmarks.cpp +++ b/toolkit/components/places/nsNavBookmarks.cpp @@ -799,11 +799,9 @@ nsNavBookmarks::InsertSeparator(int64_t aParent, *aNewItemId = -1; // Set a NULL title rather than an empty string. - nsCString voidString; - voidString.SetIsVoid(true); nsAutoCString guid(aGUID); PRTime dateAdded = RoundedPRNow(); - rv = InsertBookmarkInDB(-1, SEPARATOR, aParent, index, voidString, dateAdded, + rv = InsertBookmarkInDB(-1, SEPARATOR, aParent, index, NullCString(), dateAdded, 0, folderGuid, grandParentId, nullptr, aSource, aNewItemId, guid); NS_ENSURE_SUCCESS(rv, rv); @@ -814,7 +812,7 @@ nsNavBookmarks::InsertSeparator(int64_t aParent, NOTIFY_OBSERVERS(mCanNotify, mCacheObservers, mObservers, nsINavBookmarkObserver, OnItemAdded(*aNewItemId, aParent, index, TYPE_SEPARATOR, - nullptr, voidString, dateAdded, guid, folderGuid, + nullptr, NullCString(), dateAdded, guid, folderGuid, aSource)); return NS_OK; diff --git a/xpcom/ds/nsVariant.cpp b/xpcom/ds/nsVariant.cpp index 6edae9f4f32b..edb020139a6e 100644 --- a/xpcom/ds/nsVariant.cpp +++ b/xpcom/ds/nsVariant.cpp @@ -766,7 +766,6 @@ nsDiscriminatedUnion::ToString(nsACString& aOutString) const case nsIDataType::VTYPE_VOID: case nsIDataType::VTYPE_EMPTY: - aOutString.Truncate(); aOutString.SetIsVoid(true); return NS_OK;