[vte] [ring] Simplify a bit
- From: Behdad Esfahbod <behdad src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vte] [ring] Simplify a bit
- Date: Wed, 16 Sep 2009 02:23:47 +0000 (UTC)
commit 109f77b663e4f87e4fb148ae26cd7a566de0cb61
Author: Behdad Esfahbod <behdad behdad org>
Date: Tue Sep 15 21:22:53 2009 -0400
[ring] Simplify a bit
src/ring.c | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/src/ring.c b/src/ring.c
index c4a2376..11ccd99 100644
--- a/src/ring.c
+++ b/src/ring.c
@@ -98,6 +98,18 @@ typedef struct _VteRowRecord {
gsize attr_offset;
} VteRowRecord;
+static gboolean
+_vte_ring_read_row_record (VteRing *ring, VteRowRecord *record, guint position)
+{
+ return _vte_stream_read (ring->row_stream, position * sizeof (*record), (char *) record, sizeof (*record));
+}
+
+static void
+_vte_ring_append_row_record (VteRing *ring, const VteRowRecord *record, guint position)
+{
+ _vte_stream_append (ring->row_stream, (const char *) record, sizeof (*record));
+}
+
static void
_vte_ring_freeze_row (VteRing *ring, guint position, const VteRowData *row)
{
@@ -159,7 +171,7 @@ _vte_ring_freeze_row (VteRing *ring, guint position, const VteRowData *row)
g_string_append_c (buffer, '\n');
_vte_stream_append (ring->text_stream, buffer->str, buffer->len);
- _vte_stream_append (ring->row_stream, (const char *) &record, sizeof (record));
+ _vte_ring_append_row_record (ring, &record, position);
}
static void
@@ -179,10 +191,10 @@ _vte_ring_thaw_row (VteRing *ring, guint position, VteRowData *row, gboolean tru
attr_change.text_offset = 0;
- if (!_vte_stream_read (ring->row_stream, position * sizeof (records[0]), (char *) &records[0], sizeof (records[0])))
+ if (!_vte_ring_read_row_record (ring, &records[0], position))
return;
- if ((position + 1) * sizeof (VteRowRecord) < _vte_stream_head (ring->row_stream)) {
- if (!_vte_stream_read (ring->row_stream, (position + 1) * sizeof (records[1]), (char *) &records[1], sizeof (records[1])))
+ if ((position + 1) * sizeof (records[0]) < _vte_stream_head (ring->row_stream)) {
+ if (!_vte_ring_read_row_record (ring, &records[1], position + 1))
return;
} else
records[1].text_offset = _vte_stream_head (ring->text_stream);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]