gnucash maint: Performance fix in dom_chars_handler: use g_strndup instead of g_strdup

Geert Janssens gjanssens at code.gnucash.org
Mon Dec 24 08:24:01 EST 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/aaeb639d (commit)
	from  https://github.com/Gnucash/gnucash/commit/1a5c2dd2 (commit)



commit aaeb639d07a24725de66f2929c37d1c99328b098
Author: Christopher D. Carson <chriscarson60187 at gmail.com>
Date:   Sun Dec 23 20:48:02 2018 -0600

    Performance fix in dom_chars_handler: use g_strndup instead of g_strdup
    
    Because the origin string can be extraordinarly long, you get more
    benefit from this than you would imagine

diff --git a/libgnucash/backend/xml/sixtp-to-dom-parser.cpp b/libgnucash/backend/xml/sixtp-to-dom-parser.cpp
index e6ba430..9aba080 100644
--- a/libgnucash/backend/xml/sixtp-to-dom-parser.cpp
+++ b/libgnucash/backend/xml/sixtp-to-dom-parser.cpp
@@ -95,7 +95,7 @@ static gboolean dom_chars_handler (
 {
     if (length > 0)
     {
-        gchar* newtext = g_strdup (text);
+        gchar* newtext = g_strndup (text,length);
         xmlNodeAddContentLen ((xmlNodePtr)parent_data,
                               checked_char_cast (newtext), length);
         g_free (newtext);



Summary of changes:
 libgnucash/backend/xml/sixtp-to-dom-parser.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



More information about the gnucash-changes mailing list