1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:37:34 +00:00

LibUnicode+LibJS: Return removed extensions from remove_extension_type

Some callers will need to hold onto the removed extensions.
This commit is contained in:
Timothy Flynn 2021-09-05 18:29:11 -04:00 committed by Linus Groh
parent 50158abaf1
commit 40ea659282

View file

@ -58,14 +58,19 @@ struct LocaleID {
String to_string() const; String to_string() const;
template<typename ExtensionType> template<typename ExtensionType>
void remove_extension_type() Vector<Extension> remove_extension_type()
{ {
Vector<Extension> removed_extensions {};
auto tmp_extensions = move(extensions); auto tmp_extensions = move(extensions);
for (auto& extension : tmp_extensions) { for (auto& extension : tmp_extensions) {
if (!extension.has<ExtensionType>()) if (extension.has<ExtensionType>())
removed_extensions.append(move(extension));
else
extensions.append(move(extension)); extensions.append(move(extension));
} }
return removed_extensions;
} }
LanguageID language_id {}; LanguageID language_id {};