Skip to content

Commit

Permalink
Bug 1305202 - Use NullString() more and remove superfluous Truncates(…
Browse files Browse the repository at this point in the history
…). r=smaug
  • Loading branch information
wisniewskit committed Sep 24, 2016
1 parent 5d3595a commit ba6cb51
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 28 deletions.
10 changes: 2 additions & 8 deletions dom/ipc/Blob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions dom/json/nsJSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ nsJSON::Encode(JS::Handle<JS::Value> aValue, JSContext* cx, uint8_t aArgc,
return rv;

if (aArgc == 0) {
aJSON.Truncate();
aJSON.SetIsVoid(true);
return NS_OK;
}
Expand All @@ -83,7 +82,6 @@ nsJSON::Encode(JS::Handle<JS::Value> 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();
Expand Down
4 changes: 1 addition & 3 deletions dom/plugins/ipc/PluginMessageUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,7 @@ inline nsCString
NullableString(const char* aString)
{
if (!aString) {
nsCString str;
str.SetIsVoid(true);
return str;
return NullCString();
}
return nsCString(aString);
}
Expand Down
1 change: 0 additions & 1 deletion js/xpconnect/src/XPCConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 1 addition & 3 deletions parser/html/nsHtml5TreeOperation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,14 +565,12 @@ nsHtml5TreeOperation::AppendDoctypeToDocument(nsIAtom* aName,
// Adapted from nsXMLContentSink
// Create a new doctype node
nsCOMPtr<nsIDOMDocumentType> 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<nsIContent> asContent = do_QueryInterface(docType);
return AppendToDocument(asContent, aBuilder);
Expand Down
2 changes: 0 additions & 2 deletions storage/Variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,13 @@ class NullVariant : public Variant_base
NS_IMETHOD GetAsAUTF8String(nsACString &_str)
{
// Return a void string.
_str.Truncate(0);
_str.SetIsVoid(true);
return NS_OK;
}

NS_IMETHOD GetAsAString(nsAString &_str)
{
// Return a void string.
_str.Truncate(0);
_str.SetIsVoid(true);
return NS_OK;
}
Expand Down
2 changes: 0 additions & 2 deletions storage/mozStorageArgValueArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<const char16_t *>(::sqlite3_value_text16(mArgv[aIndex])),
Expand Down
2 changes: 0 additions & 2 deletions storage/mozStorageStatement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 =
Expand Down
6 changes: 2 additions & 4 deletions toolkit/components/places/nsNavBookmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
1 change: 0 additions & 1 deletion xpcom/ds/nsVariant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit ba6cb51

Please sign in to comment.