diff --git a/ChangeLog b/ChangeLog index 93e1397a9..f88552987 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2003-03-30 Matthias Clasen + * glib/gstring.c (g_string_new): Optimize the common cases + (init == NULL or init == "") a bit. + * glib/gmarkup.c, glib/gmessages.c, glib/gscanner.c, + glib/gshell.c, glib/gspawn-win32-helper.c, glib/gspawn-win32.c, + glib/gspawn.c, gobject/gvaluetransform.c: replace uses of + g_string_new ("") by g_string_new (NULL). (#106973, Morten Welinder) + * glib/gutf8.c (UNICODE_VALID): Update to Unicode 3.1 and optimize a bit. (#107427, Noah Lewitt) diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 93e1397a9..f88552987 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,12 @@ 2003-03-30 Matthias Clasen + * glib/gstring.c (g_string_new): Optimize the common cases + (init == NULL or init == "") a bit. + * glib/gmarkup.c, glib/gmessages.c, glib/gscanner.c, + glib/gshell.c, glib/gspawn-win32-helper.c, glib/gspawn-win32.c, + glib/gspawn.c, gobject/gvaluetransform.c: replace uses of + g_string_new ("") by g_string_new (NULL). (#106973, Morten Welinder) + * glib/gutf8.c (UNICODE_VALID): Update to Unicode 3.1 and optimize a bit. (#107427, Noah Lewitt) diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 93e1397a9..f88552987 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,5 +1,12 @@ 2003-03-30 Matthias Clasen + * glib/gstring.c (g_string_new): Optimize the common cases + (init == NULL or init == "") a bit. + * glib/gmarkup.c, glib/gmessages.c, glib/gscanner.c, + glib/gshell.c, glib/gspawn-win32-helper.c, glib/gspawn-win32.c, + glib/gspawn.c, gobject/gvaluetransform.c: replace uses of + g_string_new ("") by g_string_new (NULL). (#106973, Morten Welinder) + * glib/gutf8.c (UNICODE_VALID): Update to Unicode 3.1 and optimize a bit. (#107427, Noah Lewitt) diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 93e1397a9..f88552987 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,5 +1,12 @@ 2003-03-30 Matthias Clasen + * glib/gstring.c (g_string_new): Optimize the common cases + (init == NULL or init == "") a bit. + * glib/gmarkup.c, glib/gmessages.c, glib/gscanner.c, + glib/gshell.c, glib/gspawn-win32-helper.c, glib/gspawn-win32.c, + glib/gspawn.c, gobject/gvaluetransform.c: replace uses of + g_string_new ("") by g_string_new (NULL). (#106973, Morten Welinder) + * glib/gutf8.c (UNICODE_VALID): Update to Unicode 3.1 and optimize a bit. (#107427, Noah Lewitt) diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 93e1397a9..f88552987 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,5 +1,12 @@ 2003-03-30 Matthias Clasen + * glib/gstring.c (g_string_new): Optimize the common cases + (init == NULL or init == "") a bit. + * glib/gmarkup.c, glib/gmessages.c, glib/gscanner.c, + glib/gshell.c, glib/gspawn-win32-helper.c, glib/gspawn-win32.c, + glib/gspawn.c, gobject/gvaluetransform.c: replace uses of + g_string_new ("") by g_string_new (NULL). (#106973, Morten Welinder) + * glib/gutf8.c (UNICODE_VALID): Update to Unicode 3.1 and optimize a bit. (#107427, Noah Lewitt) diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 93e1397a9..f88552987 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,5 +1,12 @@ 2003-03-30 Matthias Clasen + * glib/gstring.c (g_string_new): Optimize the common cases + (init == NULL or init == "") a bit. + * glib/gmarkup.c, glib/gmessages.c, glib/gscanner.c, + glib/gshell.c, glib/gspawn-win32-helper.c, glib/gspawn-win32.c, + glib/gspawn.c, gobject/gvaluetransform.c: replace uses of + g_string_new ("") by g_string_new (NULL). (#106973, Morten Welinder) + * glib/gutf8.c (UNICODE_VALID): Update to Unicode 3.1 and optimize a bit. (#107427, Noah Lewitt) diff --git a/glib/gmarkup.c b/glib/gmarkup.c index a45952e7a..ea86cef99 100644 --- a/glib/gmarkup.c +++ b/glib/gmarkup.c @@ -335,7 +335,7 @@ unescape_text (GMarkupParseContext *context, UnescapeState state; const gchar *start; - str = g_string_new (""); + str = g_string_new (NULL); state = USTATE_INSIDE_TEXT; p = text; @@ -681,7 +681,7 @@ add_to_partial (GMarkupParseContext *context, const gchar *text_end) { if (context->partial_chunk == NULL) - context->partial_chunk = g_string_new (""); + context->partial_chunk = g_string_new (NULL); if (text_start != text_end) g_string_append_len (context->partial_chunk, text_start, @@ -1821,7 +1821,7 @@ g_markup_escape_text (const gchar *text, if (length < 0) length = strlen (text); - str = g_string_new (""); + str = g_string_new (NULL); append_escaped_text (str, text, length); return g_string_free (str, FALSE); diff --git a/glib/gmessages.c b/glib/gmessages.c index 4f0064c71..c593c8cee 100644 --- a/glib/gmessages.c +++ b/glib/gmessages.c @@ -767,7 +767,7 @@ g_log_default_handler (const gchar *log_domain, fd = mklevel_prefix (level_prefix, log_level); - gstring = g_string_new (""); + gstring = g_string_new (NULL); if (log_level & ALERT_LEVELS) g_string_append (gstring, "\n"); if (!log_domain) diff --git a/glib/gscanner.c b/glib/gscanner.c index 632a3eb95..a6fef9ca0 100644 --- a/glib/gscanner.c +++ b/glib/gscanner.c @@ -1267,7 +1267,7 @@ g_scanner_get_token_ll (GScanner *scanner, g_scanner_get_char (scanner, line_p, position_p); token = G_TOKEN_COMMENT_MULTI; in_comment_multi = TRUE; - gstring = g_string_new (""); + gstring = g_string_new (NULL); while ((ch = g_scanner_get_char (scanner, line_p, position_p)) != 0) { if (ch == '*' && g_scanner_peek_next_char (scanner) == '/') @@ -1287,7 +1287,7 @@ g_scanner_get_token_ll (GScanner *scanner, goto default_case; token = G_TOKEN_STRING; in_string_sq = TRUE; - gstring = g_string_new (""); + gstring = g_string_new (NULL); while ((ch = g_scanner_get_char (scanner, line_p, position_p)) != 0) { if (ch == '\'') @@ -1306,7 +1306,7 @@ g_scanner_get_token_ll (GScanner *scanner, goto default_case; token = G_TOKEN_STRING; in_string_dq = TRUE; - gstring = g_string_new (""); + gstring = g_string_new (NULL); while ((ch = g_scanner_get_char (scanner, line_p, position_p)) != 0) { if (ch == '"') @@ -1612,7 +1612,7 @@ g_scanner_get_token_ll (GScanner *scanner, { token = G_TOKEN_COMMENT_SINGLE; in_comment_single = TRUE; - gstring = g_string_new (""); + gstring = g_string_new (NULL); ch = g_scanner_get_char (scanner, line_p, position_p); while (ch != 0) { @@ -1637,7 +1637,7 @@ g_scanner_get_token_ll (GScanner *scanner, g_scanner_peek_next_char (scanner))) { token = G_TOKEN_IDENTIFIER; - gstring = g_string_new (""); + gstring = g_string_new (NULL); gstring = g_string_append_c (gstring, ch); do { diff --git a/glib/gshell.c b/glib/gshell.c index b6e5b5227..9cc49c82b 100644 --- a/glib/gshell.c +++ b/glib/gshell.c @@ -258,7 +258,7 @@ g_shell_unquote (const gchar *quoted_string, start = unquoted; end = unquoted; - retval = g_string_new (""); + retval = g_string_new (NULL); /* The loop allows cases such as * "foo"blah blah'bar'woo foo"baz"la la la\'\''foo' @@ -390,7 +390,7 @@ static inline void ensure_token (GString **token) { if (*token == NULL) - *token = g_string_new (""); + *token = g_string_new (NULL); } static void diff --git a/glib/gspawn-win32-helper.c b/glib/gspawn-win32-helper.c index 9f9af6813..0679031d6 100644 --- a/glib/gspawn-win32-helper.c +++ b/glib/gspawn-win32-helper.c @@ -37,7 +37,7 @@ write_err_and_exit (gint fd, if (debug) { - debugstring = g_string_new (""); + debugstring = g_string_new (NULL); g_string_append (debugstring, g_strdup_printf ("writing error code %d and errno %d", msg, en)); @@ -82,7 +82,7 @@ WinMain (struct HINSTANCE__ *hInstance, if (debug) { - debugstring = g_string_new (""); + debugstring = g_string_new (NULL); g_string_append (debugstring, g_strdup_printf ("g-spawn-win32-helper: " @@ -212,7 +212,7 @@ WinMain (struct HINSTANCE__ *hInstance, if (debug) { - debugstring = g_string_new (""); + debugstring = g_string_new (NULL); g_string_append (debugstring, g_strdup_printf ("calling %s %s mode=%s argv: ", (__argv[ARG_USE_PATH][0] == 'y' ? @@ -237,7 +237,7 @@ WinMain (struct HINSTANCE__ *hInstance, if (debug) { - debugstring = g_string_new (""); + debugstring = g_string_new (NULL); g_string_append (debugstring, g_strdup_printf ("%s returned %#x", (__argv[ARG_USE_PATH][0] == 'y' ? diff --git a/glib/gspawn-win32.c b/glib/gspawn-win32.c index 66cfe5380..7fd61bbc9 100644 --- a/glib/gspawn-win32.c +++ b/glib/gspawn-win32.c @@ -361,7 +361,7 @@ g_spawn_sync (const gchar *working_directory, if (outpipe >= 0) { - outstr = g_string_new (""); + outstr = g_string_new (NULL); outchannel = g_io_channel_win32_new_fd (outpipe); g_io_channel_set_encoding (outchannel, NULL, NULL); g_io_channel_win32_make_pollfd (outchannel, @@ -371,7 +371,7 @@ g_spawn_sync (const gchar *working_directory, if (errpipe >= 0) { - errstr = g_string_new (""); + errstr = g_string_new (NULL); errchannel = g_io_channel_win32_new_fd (errpipe); g_io_channel_set_encoding (errchannel, NULL, NULL); g_io_channel_win32_make_pollfd (errchannel, diff --git a/glib/gspawn.c b/glib/gspawn.c index be31eed65..2af786db4 100644 --- a/glib/gspawn.c +++ b/glib/gspawn.c @@ -263,12 +263,12 @@ g_spawn_sync (const gchar *working_directory, if (outpipe >= 0) { - outstr = g_string_new (""); + outstr = g_string_new (NULL); } if (errpipe >= 0) { - errstr = g_string_new (""); + errstr = g_string_new (NULL); } /* Read data until we get EOF on both pipes. */ diff --git a/glib/gstring.c b/glib/gstring.c index 432149676..fb93591b6 100644 --- a/glib/gstring.c +++ b/glib/gstring.c @@ -235,10 +235,17 @@ g_string_new (const gchar *init) { GString *string; - string = g_string_sized_new (init ? strlen (init) + 2 : 2); + if (init == NULL || *init == '\0') + string = g_string_sized_new (2); + else + { + gint len; - if (init) - g_string_append (string, init); + len = strlen (init); + string = g_string_sized_new (len + 2); + + g_string_append_len (string, init, len); + } return string; } diff --git a/gobject/gvaluetransform.c b/gobject/gvaluetransform.c index 917d8e9a4..20e473eae 100644 --- a/gobject/gvaluetransform.c +++ b/gobject/gvaluetransform.c @@ -210,7 +210,7 @@ value_transform_flags_string (const GValue *src_value, if (flags_value) { - GString *gstring = g_string_new (""); + GString *gstring = g_string_new (NULL); guint v_flags = src_value->data[0].v_uint; do