summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Larsson <alexl@redhat.com>2002-02-13 21:45:07 +0000
committerAlexander Larsson <alexl@src.gnome.org>2002-02-13 21:45:07 +0000
commit85a4366f8c9afb6876e2b1dda35962ca8c5915ce (patch)
treea6bc6c99c7e086e1edc346a6855daffc6e68b08d
parent2dfffdca3dd31631a0c1a6345d5c5354233a379b (diff)
downloadyelp-85a4366f8c9afb6876e2b1dda35962ca8c5915ce.tar.gz
Implement buffering writes for generated html.
2002-02-13 Alex Larsson <alexl@redhat.com> * src/yelp-view-toc.c (yelp_view_toc_write, yelp_view_toc_close, yelp_view_toc_open): Implement buffering writes for generated html.
-rw-r--r--ChangeLog6
-rw-r--r--src/yelp-view-toc.c34
2 files changed, 36 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 3f2e7c5f..61794579 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2002-02-13 Alex Larsson <alexl@redhat.com>
+ * src/yelp-view-toc.c (yelp_view_toc_write, yelp_view_toc_close,
+ yelp_view_toc_open):
+ Implement buffering writes for generated html.
+
+2002-02-13 Alex Larsson <alexl@redhat.com>
+
* src/Makefile.am (install-local):
Remove old gnome-help binary, if any.
diff --git a/src/yelp-view-toc.c b/src/yelp-view-toc.c
index 7a993168..1f033e84 100644
--- a/src/yelp-view-toc.c
+++ b/src/yelp-view-toc.c
@@ -62,11 +62,15 @@ struct YelpImportantDocsSection {
GList *seriesids;
};
+#define BUFFER_SIZE 4096
+
struct _YelpViewTOCPriv {
GtkWidget *html_view;
HtmlDocument *doc;
GNode *doc_tree;
GList *important_sections;
+ char buffer[BUFFER_SIZE];
+ int buffer_pos;
};
GType
@@ -145,18 +149,29 @@ static void
yelp_view_toc_open (YelpViewTOC *view)
{
html_document_open_stream (view->priv->doc, "text/html");
+ view->priv->buffer_pos = 0;
}
static void
yelp_view_toc_close (YelpViewTOC *view)
{
- /* TODO: If buffering, flush buffers */
+ YelpViewTOCPriv *priv = view->priv;
+
+ if (priv->buffer_pos > 0) {
+ html_document_write_stream (priv->doc, priv->buffer, priv->buffer_pos);
+ priv->buffer_pos = 0;
+ }
+
+
html_document_close_stream (view->priv->doc);
}
static void
yelp_view_toc_write (YelpViewTOC *view, char *data, int len)
{
+ YelpViewTOCPriv *priv = view->priv;
+ int chunk_size;
+
if (len < 0) {
len = strlen (data);
}
@@ -165,9 +180,20 @@ yelp_view_toc_write (YelpViewTOC *view, char *data, int len)
g_print ("%.*s", len,data);
#endif
- /* TODO: Maybe we should be buffering writes */
-
- html_document_write_stream (view->priv->doc, data, len);
+ while (len > 0) {
+ chunk_size = MIN (BUFFER_SIZE - priv->buffer_pos, len);
+
+ memcpy (priv->buffer + priv->buffer_pos, data, chunk_size);
+ priv->buffer_pos += chunk_size;
+ len -= chunk_size;
+ data += chunk_size;
+
+ if (priv->buffer_pos == BUFFER_SIZE) {
+ html_document_write_stream (priv->doc, priv->buffer, BUFFER_SIZE);
+ priv->buffer_pos = 0;
+ }
+
+ }
}
static void