[librsvg] rsvg_load_read_stream_sync(): Removed; inlined in its only two callers
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] rsvg_load_read_stream_sync(): Removed; inlined in its only two callers
- Date: Mon, 10 Dec 2018 20:54:43 +0000 (UTC)
commit 654ae2128b1bc6c66fa8a172f2f96e2798022b4e
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Dec 10 14:48:45 2018 -0600
rsvg_load_read_stream_sync(): Removed; inlined in its only two callers
librsvg/rsvg-handle.c | 38 +++++++++++++++++++-------------------
librsvg/rsvg-load.c | 38 +++++++-------------------------------
librsvg/rsvg-load.h | 6 ------
librsvg/rsvg-private.h | 18 ++++++++++++++++++
4 files changed, 44 insertions(+), 56 deletions(-)
---
diff --git a/librsvg/rsvg-handle.c b/librsvg/rsvg-handle.c
index ae022dc8..70c9ca39 100644
--- a/librsvg/rsvg-handle.c
+++ b/librsvg/rsvg-handle.c
@@ -692,15 +692,8 @@ rsvg_handle_write (RsvgHandle *handle, const guchar *buf, gsize count, GError **
}
static gboolean
-finish_load (RsvgHandle *handle, gboolean was_successful, GError **error)
+finish_load (RsvgHandle *handle, RsvgXmlState *xml, gboolean was_successful, GError **error)
{
- RsvgXmlState *xml;
-
- g_assert (handle->priv->load != NULL);
-
- xml = rsvg_load_free (handle->priv->load);
- handle->priv->load = NULL;
-
if (was_successful) {
g_assert (error == NULL || *error == NULL);
@@ -710,8 +703,6 @@ finish_load (RsvgHandle *handle, gboolean was_successful, GError **error)
}
}
- rsvg_xml_state_free (xml);
-
if (was_successful) {
handle->priv->hstate = RSVG_HANDLE_STATE_CLOSED_OK;
} else {
@@ -738,6 +729,7 @@ rsvg_handle_close (RsvgHandle *handle, GError **error)
RsvgHandlePrivate *priv;
gboolean read_successfully;
gboolean result = FALSE;
+ RsvgXmlState *xml;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
rsvg_return_val_if_fail (handle, FALSE, error);
@@ -754,7 +746,12 @@ rsvg_handle_close (RsvgHandle *handle, GError **error)
case RSVG_HANDLE_STATE_LOADING:
g_assert (priv->load != NULL);
read_successfully = rsvg_load_close (priv->load, error);
- result = finish_load (handle, read_successfully, error);
+
+ xml = rsvg_load_free (priv->load);
+ priv->load = NULL;
+
+ result = finish_load (handle, xml, read_successfully, error);
+ rsvg_xml_state_free (xml);
break;
case RSVG_HANDLE_STATE_CLOSED_OK:
@@ -801,7 +798,7 @@ rsvg_handle_read_stream_sync (RsvgHandle *handle,
RsvgHandlePrivate *priv;
gboolean read_successfully;
gboolean result;
- RsvgLoad *saved_load;
+ RsvgXmlState *xml;
g_return_val_if_fail (RSVG_IS_HANDLE (handle), FALSE);
g_return_val_if_fail (G_IS_INPUT_STREAM (stream), FALSE);
@@ -814,14 +811,17 @@ rsvg_handle_read_stream_sync (RsvgHandle *handle,
priv->hstate = RSVG_HANDLE_STATE_LOADING;
- saved_load = priv->load;
+ xml = rsvg_xml_state_new (handle);
+ read_successfully = rsvg_xml_state_load_from_possibly_compressed_stream (
+ xml,
+ (priv->flags && RSVG_HANDLE_FLAG_UNLIMITED) != 0,
+ stream,
+ cancellable,
+ error
+ );
- priv->load = rsvg_load_new (handle);
-
- read_successfully = rsvg_load_read_stream_sync (priv->load, stream, cancellable, error);
- result = finish_load (handle, read_successfully, error);
-
- priv->load = saved_load;
+ result = finish_load (handle, xml, read_successfully, error);
+ rsvg_xml_state_free (xml);
return result;
}
diff --git a/librsvg/rsvg-load.c b/librsvg/rsvg-load.c
index ee1ca85a..b32f8c9c 100644
--- a/librsvg/rsvg-load.c
+++ b/librsvg/rsvg-load.c
@@ -35,17 +35,6 @@ typedef enum {
LOAD_STATE_CLOSED
} LoadState;
-/* Implemented in rsvg_internals/src/xml.rs */
-extern RsvgXmlState *rsvg_xml_state_new (RsvgHandle *handle);
-extern void rsvg_xml_state_error(RsvgXmlState *xml, const char *msg);
-
-/* Implemented in rsvg_internals/src/xml2_load.rs */
-extern gboolean rsvg_xml_state_load_from_possibly_compressed_stream (RsvgXmlState *xml,
- gboolean unlimited_size,
- GInputStream *stream,
- GCancellable *cancellable,
- GError **error);
-
/* Holds the GIO and loading state for compressed data */
struct RsvgLoad {
RsvgHandle *handle;
@@ -106,25 +95,6 @@ rsvg_sax_error_cb (void *data, const char *msg, ...)
g_free (buf);
}
-gboolean
-rsvg_load_read_stream_sync (RsvgLoad *load,
- GInputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- gboolean res = FALSE;
- gboolean unlimited_size = (rsvg_handle_get_flags (load->handle) && RSVG_HANDLE_FLAG_UNLIMITED) != 0;
-
- res = rsvg_xml_state_load_from_possibly_compressed_stream (load->rust_state,
- unlimited_size,
- stream,
- cancellable,
- error);
- load->state = LOAD_STATE_CLOSED;
-
- return res;
-}
-
gboolean
rsvg_load_write (RsvgLoad *load, const guchar *buf, gsize count, GError **error)
{
@@ -162,6 +132,7 @@ rsvg_load_close (RsvgLoad *load, GError **error)
case LOAD_STATE_READING: {
GInputStream *stream;
GBytes *bytes;
+ gboolean unlimited_size = (rsvg_handle_get_flags (load->handle) && RSVG_HANDLE_FLAG_UNLIMITED) != 0;
bytes = g_byte_array_free_to_bytes (load->buffer);
load->buffer = NULL;
@@ -169,7 +140,12 @@ rsvg_load_close (RsvgLoad *load, GError **error)
stream = g_memory_input_stream_new_from_bytes (bytes);
g_bytes_unref (bytes);
- res = rsvg_load_read_stream_sync (load, stream, NULL, error);
+ res = rsvg_xml_state_load_from_possibly_compressed_stream (load->rust_state,
+ unlimited_size,
+ stream,
+ NULL,
+ error);
+
g_clear_object (&stream);
break;
}
diff --git a/librsvg/rsvg-load.h b/librsvg/rsvg-load.h
index 0f52c515..d9253da9 100644
--- a/librsvg/rsvg-load.h
+++ b/librsvg/rsvg-load.h
@@ -25,9 +25,6 @@
#include <glib.h>
#include "rsvg-private.h"
-/* Implemented in rsvg_internals/src/xml.rs */
-typedef struct RsvgXmlState RsvgXmlState;
-
G_GNUC_INTERNAL
RsvgLoad *rsvg_load_new (RsvgHandle *handle) G_GNUC_WARN_UNUSED_RESULT;
@@ -40,7 +37,4 @@ gboolean rsvg_load_write (RsvgLoad *load, const guchar *buf, gsize count, GError
G_GNUC_INTERNAL
gboolean rsvg_load_close (RsvgLoad *load, GError **error) G_GNUC_WARN_UNUSED_RESULT;
-G_GNUC_INTERNAL
-gboolean rsvg_load_read_stream_sync (RsvgLoad *load, GInputStream *stream, GCancellable *cancellable, GError
**error) G_GNUC_WARN_UNUSED_RESULT;
-
#endif
diff --git a/librsvg/rsvg-private.h b/librsvg/rsvg-private.h
index c205f551..3d4afc40 100644
--- a/librsvg/rsvg-private.h
+++ b/librsvg/rsvg-private.h
@@ -113,6 +113,24 @@ struct RsvgHandlePrivate {
RsvgHandleRust *rust_handle;
};
+/* Implemented in rsvg_internals/src/xml.rs */
+typedef struct RsvgXmlState RsvgXmlState;
+
+/* Implemented in rsvg_internals/src/xml.rs */
+G_GNUC_INTERNAL
+RsvgXmlState *rsvg_xml_state_new (RsvgHandle *handle);
+
+G_GNUC_INTERNAL
+void rsvg_xml_state_error(RsvgXmlState *xml, const char *msg);
+
+/* Implemented in rsvg_internals/src/xml2_load.rs */
+G_GNUC_INTERNAL
+gboolean rsvg_xml_state_load_from_possibly_compressed_stream (RsvgXmlState *xml,
+ gboolean unlimited_size,
+ GInputStream *stream,
+ GCancellable *cancellable,
+ GError **error);
+
G_GNUC_INTERNAL
GdkPixbuf *rsvg_cairo_surface_to_pixbuf (cairo_surface_t *surface);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]