зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1485161: Make gfxPlatform::GetDefaultFontName() return nsAutoString, to enable possibility of Return Value Optimization & to address build warning. r=jfkthame
This function uses a nsAutoString internally, and its caller stores its returned value in a nsAutoString. So it's silly for us to have it return a different type (nsString). With this change, the compiler should be able to perform return value optimization and avoid the need for any copying/reallocation of this function's return value. Differential Revision: https://phabricator.services.mozilla.com/D3926 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
a0fedd95f1
Коммит
5584dee150
|
@ -1653,17 +1653,20 @@ gfxPlatform::GetStandardFamilyName(const nsAString& aFontName,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsString
|
||||
nsAutoString
|
||||
gfxPlatform::GetDefaultFontName(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily)
|
||||
{
|
||||
// To benefit from Return Value Optimization, all paths here must return
|
||||
// this one variable:
|
||||
nsAutoString result;
|
||||
|
||||
gfxFontFamily* fontFamily = gfxPlatformFontList::PlatformFontList()->
|
||||
GetDefaultFontFamily(aLangGroup, aGenericFamily);
|
||||
if (!fontFamily) {
|
||||
return EmptyString();
|
||||
}
|
||||
nsAutoString result;
|
||||
fontFamily->LocalizedName(result);
|
||||
if (fontFamily) {
|
||||
fontFamily->LocalizedName(result);
|
||||
} // (else, leave 'result' empty)
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -377,8 +377,8 @@ public:
|
|||
* available in the system, this may return second or later font in the
|
||||
* pref. If there are no available fonts in the pref, returns empty string.
|
||||
*/
|
||||
nsString GetDefaultFontName(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily);
|
||||
nsAutoString GetDefaultFontName(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily);
|
||||
|
||||
/**
|
||||
* Create the appropriate platform font group
|
||||
|
|
Загрузка…
Ссылка в новой задаче