mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-11-04 01:58:54 +01:00 
			
		
		
		
	Microoptimize string reallocations
This commit is contained in:
		@@ -3477,19 +3477,16 @@ handle_get_all_properties (GDBusConnection *connection,
 | 
			
		||||
 | 
			
		||||
/* ---------------------------------------------------------------------------------------------------- */
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
introspect_append_header (GString *s)
 | 
			
		||||
{
 | 
			
		||||
  g_string_append (s,
 | 
			
		||||
                   "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
 | 
			
		||||
                   "<!-- GDBus 0.1 -->\n"
 | 
			
		||||
                   "<node>\n");
 | 
			
		||||
}
 | 
			
		||||
static const gchar introspect_header[] =
 | 
			
		||||
  "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
 | 
			
		||||
  "                      \"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
 | 
			
		||||
  "<!-- GDBus " PACKAGE_VERSION " -->\n"
 | 
			
		||||
  "<node>\n";
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
introspect_append_standard_interfaces (GString *s)
 | 
			
		||||
{
 | 
			
		||||
  g_string_append (s,
 | 
			
		||||
static const gchar introspect_tail[] =
 | 
			
		||||
  "</node>\n";
 | 
			
		||||
 | 
			
		||||
static const gchar introspect_standard_interfaces[] =
 | 
			
		||||
  "  <interface name=\"org.freedesktop.DBus.Properties\">\n"
 | 
			
		||||
  "    <method name=\"Get\">\n"
 | 
			
		||||
  "      <arg type=\"s\" name=\"interface_name\" direction=\"in\"/>\n"
 | 
			
		||||
@@ -3520,7 +3517,18 @@ introspect_append_standard_interfaces (GString *s)
 | 
			
		||||
  "    <method name=\"GetMachineId\">\n"
 | 
			
		||||
  "      <arg type=\"s\" name=\"machine_uuid\" direction=\"out\"/>\n"
 | 
			
		||||
  "    </method>\n"
 | 
			
		||||
                   "  </interface>\n");
 | 
			
		||||
  "  </interface>\n";
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
introspect_append_header (GString *s)
 | 
			
		||||
{
 | 
			
		||||
  g_string_append (s, introspect_header);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
introspect_append_standard_interfaces (GString *s)
 | 
			
		||||
{
 | 
			
		||||
  g_string_append (s, introspect_standard_interfaces);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
@@ -3624,7 +3632,9 @@ handle_introspect (GDBusConnection *connection,
 | 
			
		||||
  gchar **registered;
 | 
			
		||||
 | 
			
		||||
  /* first the header with the standard interfaces */
 | 
			
		||||
  s = g_string_new (NULL);
 | 
			
		||||
  s = g_string_sized_new (sizeof (introspect_header) +
 | 
			
		||||
                          sizeof (introspect_standard_interfaces) +
 | 
			
		||||
                          sizeof (introspect_tail));
 | 
			
		||||
  introspect_append_header (s);
 | 
			
		||||
  introspect_append_standard_interfaces (s);
 | 
			
		||||
 | 
			
		||||
@@ -3642,7 +3652,7 @@ handle_introspect (GDBusConnection *connection,
 | 
			
		||||
      g_string_append_printf (s, "  <node name=\"%s\"/>\n", registered[n]);
 | 
			
		||||
    }
 | 
			
		||||
  g_strfreev (registered);
 | 
			
		||||
  g_string_append (s, "</node>\n");
 | 
			
		||||
  g_string_append (s, introspect_tail);
 | 
			
		||||
 | 
			
		||||
  reply = g_dbus_message_new_method_reply (message);
 | 
			
		||||
  g_dbus_message_set_body (reply, g_variant_new ("(s)", s->str));
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user