浏览代码

Kernel: Avoid potential allocation when enumerating cpu features

We can use `StringView::for_each_split_view` here to avoid the potential
allocation of `Vector<StringView>` elements we would get from the normal
Split view functions.
Brian Gianforcaro 3 年之前
父节点
当前提交
9592ba3548
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      Kernel/GlobalProcessExposed.cpp

+ 3 - 1
Kernel/GlobalProcessExposed.cpp

@@ -563,8 +563,10 @@ private:
                 obj.add("family", info.display_family());
                 obj.add("family", info.display_family());
 
 
                 auto features_array = obj.add_array("features");
                 auto features_array = obj.add_array("features");
-                for (auto& feature : info.features().split_view(' '))
+                auto keep_empty = false;
+                info.features().for_each_split_view(' ', keep_empty, [&](StringView feature) {
                     features_array.add(feature);
                     features_array.add(feature);
+                });
                 features_array.finish();
                 features_array.finish();
 
 
                 obj.add("model", info.display_model());
                 obj.add("model", info.display_model());