Bug 451058 - Address post-review comments.

This addresses some comments that were brought up after the code had already
landed.
r=Neil
This commit is contained in:
Shawn Wilsher 2008-08-29 16:46:14 -04:00
parent 44a275974f
commit 76d3a2e23b

View File

@ -235,7 +235,7 @@ struct variant_text_traits<nsString>
static inline nsresult asUTF8String(const nsString &aValue,
nsACString &_result)
{
_result = NS_ConvertUTF16toUTF8(aValue);
CopyUTF16toUTF8(aValue, _result);
return NS_OK;
}
static inline nsresult asString(const nsString &aValue,
@ -263,8 +263,8 @@ struct variant_storage_traits<PRUint8[]>
static inline StorageType storage_conversion(ConstructorType aBlob)
{
nsTArray<PRUint8> data(aBlob.second);
for (int i = 0; i < aBlob.second; i++)
data.InsertElementAt(i, static_cast<const PRUint8 *>(aBlob.first)[i]);
(void)data.AppendElements(static_cast<const PRUint8 *>(aBlob.first),
aBlob.second);
return data;
}
};
@ -276,13 +276,9 @@ struct variant_blob_traits<PRUint8[]>
void **_result)
{
// Copy the array
*_result = NS_Alloc(sizeof(PRUint8) * aData.Length());
*_result = nsMemory::Clone(aData.Elements(), aData.Length() * sizeof(PRUint8));
NS_ENSURE_TRUE(*_result, NS_ERROR_OUT_OF_MEMORY);
PRUint8 *result = static_cast<PRUint8 *>(*_result);
for (PRUint32 i = 0; i < aData.Length(); i++)
result[i] = aData[i];
// Set type and size
*_type = nsIDataType::VTYPE_UINT8;
*_size = aData.Length();