From 9592ba3548da7c09ddfa861a28bb4517cd06c6b9 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Mon, 10 Jan 2022 00:52:21 -0800 Subject: [PATCH] Kernel: Avoid potential allocation when enumerating cpu features We can use `StringView::for_each_split_view` here to avoid the potential allocation of `Vector` elements we would get from the normal Split view functions. --- Kernel/GlobalProcessExposed.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Kernel/GlobalProcessExposed.cpp b/Kernel/GlobalProcessExposed.cpp index 0bc2c4da48..396da168d9 100644 --- a/Kernel/GlobalProcessExposed.cpp +++ b/Kernel/GlobalProcessExposed.cpp @@ -563,8 +563,10 @@ private: obj.add("family", info.display_family()); 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.finish(); obj.add("model", info.display_model());