summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: deca98c)
raw | patch | inline | side by side (parent: deca98c)
author | mental <mental@users.sourceforge.net> | |
Mon, 22 May 2006 05:39:09 +0000 (05:39 +0000) | ||
committer | mental <mental@users.sourceforge.net> | |
Mon, 22 May 2006 05:39:09 +0000 (05:39 +0000) |
ChangeLog | patch | blob | history | |
src/extension/internal/svg.cpp | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index 5331377b6dbf9f14b37a839f2a5019858ef34e2b..e7ce13d050ab1a9d3b9c25844070186ac9931c6a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-05-22 MenTaLguY <mental@rydia.net>
+
+ * src/extension/internal/svg.cpp:
+
+ replace EXTREMELY inefficient (O(n^2), I think?) stacked C string
+ concatenations with appends to a std::vector, which is amortized O(1)
+
2006-05-21 Marco Scholten <mscholtn@xs4all.nl>
* src/ui/dialog/inkscape-preferences.cpp,
index 5f8517c3d33fcfd8905d3ec99b38d95b232b552b..ab9c59830f99df36bf2cf958884af4ec25c25e5d 100644 (file)
#include "file.h"
#include "extension/system.h"
#include "extension/output.h"
+#include <vector>
#ifdef WITH_GNOME_VFS
# include <libgnomevfs/gnome-vfs.h>
{
GnomeVFSHandle *handle = NULL;
GnomeVFSFileSize bytes_read;
- gchar buffer[BUF_SIZE] = "";
- gchar *doc = NULL;
- gchar *new_doc = NULL;
gsize bytesRead = 0;
gsize bytesWritten = 0;
g_warning(gnome_vfs_result_to_string(result));
}
+ std::vector<gchar> doc;
while (result == GNOME_VFS_OK) {
+ gchar buffer[BUF_SIZE];
result = gnome_vfs_read (handle, buffer, BUF_SIZE, &bytes_read);
- buffer[bytes_read] = '\0';
-
- if (doc == NULL) {
- doc = g_strndup(buffer, bytes_read);
- } else {
- new_doc = g_strconcat(doc, buffer, NULL);
- g_free(doc);
- doc = new_doc;
- }
+ doc.insert(doc.end(), buffer, buffer+bytes_read);
}
- return doc;
+ return g_strndup(&doc[0], doc.size());
}
#endif