зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1265902 - part 2 - don't construct unnecessary string temporaries in TransferablesToIPCTransferables; r=mccr8
Assignment works just fine here, is clearer, and avoids unnecessary work.
This commit is contained in:
Родитель
98cfb0e977
Коммит
86d79217ed
|
@ -7363,14 +7363,14 @@ nsContentUtils::TransferableToIPCTransferable(nsITransferable* aTransferable,
|
|||
nsAutoString dataAsString;
|
||||
text->GetData(dataAsString);
|
||||
IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
|
||||
item->flavor() = nsCString(flavorStr);
|
||||
item->data() = nsString(dataAsString);
|
||||
item->flavor() = flavorStr;
|
||||
item->data() = dataAsString;
|
||||
} else if (ctext) {
|
||||
nsAutoCString dataAsString;
|
||||
ctext->GetData(dataAsString);
|
||||
IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
|
||||
item->flavor() = nsCString(flavorStr);
|
||||
item->data() = nsCString(dataAsString);
|
||||
item->flavor() = flavorStr;
|
||||
item->data() = dataAsString;
|
||||
} else {
|
||||
nsCOMPtr<nsISupportsInterfacePointer> sip =
|
||||
do_QueryInterface(data);
|
||||
|
@ -7382,7 +7382,7 @@ nsContentUtils::TransferableToIPCTransferable(nsITransferable* aTransferable,
|
|||
nsCOMPtr<nsIInputStream> stream(do_QueryInterface(data));
|
||||
if (stream) {
|
||||
IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
|
||||
item->flavor() = nsCString(flavorStr);
|
||||
item->flavor() = flavorStr;
|
||||
|
||||
nsCString imageData;
|
||||
NS_ConsumeStream(stream, UINT32_MAX, imageData);
|
||||
|
@ -7405,7 +7405,7 @@ nsContentUtils::TransferableToIPCTransferable(nsITransferable* aTransferable,
|
|||
nsContentUtils::GetSurfaceData(dataSurface, &length, &stride);
|
||||
|
||||
IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
|
||||
item->flavor() = nsCString(flavorStr);
|
||||
item->flavor() = flavorStr;
|
||||
// Turn item->data() into an nsCString prior to accessing it.
|
||||
item->data() = EmptyCString();
|
||||
item->data().get_nsCString().Adopt(surfaceData.release(), length);
|
||||
|
@ -7481,7 +7481,7 @@ nsContentUtils::TransferableToIPCTransferable(nsITransferable* aTransferable,
|
|||
}
|
||||
|
||||
IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
|
||||
item->flavor() = nsCString(flavorStr);
|
||||
item->flavor() = flavorStr;
|
||||
item->data() = data;
|
||||
} else {
|
||||
// This is a hack to support kFilePromiseMime.
|
||||
|
@ -7490,12 +7490,12 @@ nsContentUtils::TransferableToIPCTransferable(nsITransferable* aTransferable,
|
|||
// nsContentAreaDragDropDataProvider as nsIFlavorDataProvider.
|
||||
if (flavorStr.EqualsLiteral(kFilePromiseMime)) {
|
||||
IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
|
||||
item->flavor() = nsCString(flavorStr);
|
||||
item->flavor() = flavorStr;
|
||||
item->data() = NS_ConvertUTF8toUTF16(flavorStr);
|
||||
} else if (!data) {
|
||||
// Empty element, transfer only the flavor
|
||||
IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
|
||||
item->flavor() = nsCString(flavorStr);
|
||||
item->flavor() = flavorStr;
|
||||
item->data() = EmptyCString();
|
||||
continue;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче