base: don't copy Xml_node

Issue #5411
This commit is contained in:
Norman Feske 2025-03-24 11:46:26 +01:00
parent 25d4b8f944
commit f3e4e04de7
3 changed files with 19 additions and 16 deletions

View File

@ -166,7 +166,7 @@ void Genode::List_model<ELEM>::update_from_xml(Xml_node const &node,
ELEM *last_updated = nullptr; /* used for appending to 'updated_list' */
node.for_each_sub_node([&] (Xml_node sub_node) {
node.for_each_sub_node([&] (Xml_node const &sub_node) {
/* skip XML nodes that are unrelated to the data model */
if (!ELEM::type_matches(sub_node))

View File

@ -126,7 +126,7 @@ namespace {
Tslab<Service::Session, 4000> _session_slab { &_sliced_heap };
void _handle_session_request(Xml_node, char const *type);
void _handle_session_request(Xml_node const &, char const *type);
void _handle_session_requests();
Service_registry _services { };
@ -152,7 +152,7 @@ namespace {
}
void Root_proxy::_handle_session_request(Xml_node request, char const *type)
void Root_proxy::_handle_session_request(Xml_node const &request, char const *type)
{
if (!request.has_attribute("id") || !request.has_type(type))
return;
@ -235,13 +235,13 @@ void Root_proxy::_handle_session_requests()
* step. If we served the new client before the old one, it would look like
* an attempt to create a second session.
*/
requests.for_each_sub_node([&] (Xml_node request) {
requests.for_each_sub_node([&] (Xml_node const &request) {
_handle_session_request(request, "upgrade"); });
requests.for_each_sub_node([&] (Xml_node request) {
requests.for_each_sub_node([&] (Xml_node const &request) {
_handle_session_request(request, "close"); });
requests.for_each_sub_node([&] (Xml_node request) {
requests.for_each_sub_node([&] (Xml_node const &request) {
_handle_session_request(request, "create"); });
}

View File

@ -241,7 +241,7 @@ struct Formatted_xml_attribute
/**
* Print attributes of XML node
*/
static void print_xml_attr_info(Output &output, Xml_node node, int indent = 0)
static void print_xml_attr_info(Output &output, Xml_node const &node, int indent = 0)
{
node.for_each_attribute([&] (Xml_attribute const &a) {
print(output, Formatted_xml_attribute(a, indent), "\n"); });
@ -256,10 +256,10 @@ static void print_xml_attr_info(Output &output, Xml_node node, int indent = 0)
*/
struct Formatted_xml_node
{
Xml_node const _node;
unsigned const _indent;
Xml_node const &_node;
unsigned const _indent;
Formatted_xml_node(Xml_node node, unsigned indent = 0)
Formatted_xml_node(Xml_node const &node, unsigned indent = 0)
: _node(node), _indent(indent) { }
void print(Output &output) const
@ -295,14 +295,17 @@ struct Formatted_xml_node
/**
* Print content of sub node with specified type
*/
static void log_key(Xml_node node, char const *key)
static void log_key(Xml_node const &node, char const *key)
{
try {
Xml_node sub_node = node.sub_node(key);
sub_node.with_raw_content([&] (char const *start, size_t length) {
log("content of sub node \"", key, "\" = \"", Cstring(start, length), "\""); });
} catch (Xml_node::Nonexistent_sub_node) {
log("sub node \"", key, "\" is not defined\n");
node.with_sub_node(key,
[&] (Xml_node const &sub_node) {
sub_node.with_raw_content([&] (char const *start, size_t length) {
log("content of sub node \"", key, "\" = \"", Cstring(start, length), "\""); });
},
[&] {
log("sub node \"", key, "\" is not defined\n");
});
} catch (Xml_node::Invalid_syntax) {
log("invalid syntax of node \"", key, "\"");
}