Bug 1385324 - Part 1: Use a preallocated buffer of 100 elements to try to avoid memory allocations in HTMLFormControlsCollection::GetSortedControls(); r=qdot

This commit is contained in:
Ehsan Akhgari 2017-07-28 11:33:41 -04:00
Родитель bce164765e
Коммит 39304e1fa4
1 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -1021,7 +1021,9 @@ HTMLFormElement::NotifySubmitObservers(nsIURI* aActionURL,
nsresult
HTMLFormElement::WalkFormElements(HTMLFormSubmission* aFormSubmission)
{
nsTArray<nsGenericHTMLFormElement*> sortedControls;
// This shouldn't be called recursively, so use a rather large value
// for the preallocated buffer.
AutoTArray<nsGenericHTMLFormElement*, 100> sortedControls;
nsresult rv = mControls->GetSortedControls(sortedControls);
NS_ENSURE_SUCCESS(rv, rv);
@ -1868,7 +1870,9 @@ HTMLFormElement::CheckFormValidity(nsIMutableArray* aInvalidElements) const
{
bool ret = true;
nsTArray<nsGenericHTMLFormElement*> sortedControls;
// This shouldn't be called recursively, so use a rather large value
// for the preallocated buffer.
AutoTArray<nsGenericHTMLFormElement*, 100> sortedControls;
if (NS_FAILED(mControls->GetSortedControls(sortedControls))) {
return false;
}