Ver Fonte

LibUnicode+LibJS: Return removed extensions from remove_extension_type

Some callers will need to hold onto the removed extensions.
Timothy Flynn há 3 anos atrás
pai
commit
40ea659282
1 ficheiros alterados com 7 adições e 2 exclusões
  1. 7 2
      Userland/Libraries/LibUnicode/Locale.h

+ 7 - 2
Userland/Libraries/LibUnicode/Locale.h

@@ -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 {};