[vte] ring: Don't create streams for the alternate screen
- From: Egmont Koblinger <egmontkob src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] ring: Don't create streams for the alternate screen
- Date: Sun, 14 Dec 2014 22:27:04 +0000 (UTC)
commit 51cc5a7507ea28123c915ee8c5cfd7a10948bbf0
Author: Egmont Koblinger <egmont gmail com>
Date: Sun Dec 14 23:21:17 2014 +0100
ring: Don't create streams for the alternate screen
https://bugzilla.gnome.org/show_bug.cgi?id=741480
src/ring.c | 29 +++++++++++++++++++++--------
src/ring.h | 3 ++-
src/vte.c | 4 ++--
3 files changed, 25 insertions(+), 11 deletions(-)
---
diff --git a/src/ring.c b/src/ring.c
index 59330b2..2451871 100644
--- a/src/ring.c
+++ b/src/ring.c
@@ -51,7 +51,7 @@ _vte_ring_validate (VteRing * ring)
void
-_vte_ring_init (VteRing *ring, gulong max_rows)
+_vte_ring_init (VteRing *ring, gulong max_rows, gboolean has_streams)
{
_vte_debug_print(VTE_DEBUG_RING, "New ring %p.\n", ring);
@@ -62,9 +62,14 @@ _vte_ring_init (VteRing *ring, gulong max_rows)
ring->mask = 31;
ring->array = g_malloc0 (sizeof (ring->array[0]) * (ring->mask + 1));
- ring->attr_stream = _vte_file_stream_new ();
- ring->text_stream = _vte_file_stream_new ();
- ring->row_stream = _vte_file_stream_new ();
+ ring->has_streams = has_streams;
+ if (has_streams) {
+ ring->attr_stream = _vte_file_stream_new ();
+ ring->text_stream = _vte_file_stream_new ();
+ ring->row_stream = _vte_file_stream_new ();
+ } else {
+ ring->attr_stream = ring->text_stream = ring->row_stream = NULL;
+ }
ring->last_attr_text_start_offset = 0;
ring->last_attr.i = basic_cell.i.attr;
@@ -133,6 +138,8 @@ _vte_ring_freeze_row (VteRing *ring, gulong position, const VteRowData *row)
_vte_debug_print (VTE_DEBUG_RING, "Freezing row %lu.\n", position);
+ g_assert(ring->has_streams);
+
memset(&record, 0, sizeof (record));
record.text_start_offset = _vte_stream_head (ring->text_stream);
record.attr_start_offset = _vte_stream_head (ring->attr_stream);
@@ -206,6 +213,8 @@ _vte_ring_thaw_row (VteRing *ring, gulong position, VteRowData *row, gboolean do
_vte_debug_print (VTE_DEBUG_RING, "Thawing row %lu.\n", position);
+ g_assert(ring->has_streams);
+
_vte_row_data_clear (row);
attr_change.text_end_offset = 0;
@@ -308,9 +317,11 @@ _vte_ring_reset_streams (VteRing *ring, gulong position)
{
_vte_debug_print (VTE_DEBUG_RING, "Reseting streams to %lu.\n", position);
- _vte_stream_reset (ring->row_stream, position * sizeof (VteRowRecord));
- _vte_stream_reset (ring->text_stream, 0);
- _vte_stream_reset (ring->attr_stream, 0);
+ if (ring->has_streams) {
+ _vte_stream_reset (ring->row_stream, position * sizeof (VteRowRecord));
+ _vte_stream_reset (ring->text_stream, 0);
+ _vte_stream_reset (ring->attr_stream, 0);
+ }
ring->last_attr_text_start_offset = 0;
ring->last_attr.i = basic_cell.i.attr;
@@ -608,7 +619,9 @@ _vte_ring_append (VteRing * ring)
* _vte_ring_set_visible_rows_hint:
* @ring: a #VteRing
*
- * Set the number of visible rows, a hint only for better performance.
+ * Set the number of visible rows, a hint for better performance.
+ * It's no longer a hint only; it's required to be set correctly
+ * for the alternate screen so that it never hits the streams.
*/
void
_vte_ring_set_visible_rows_hint (VteRing *ring, gulong rows)
diff --git a/src/ring.h b/src/ring.h
index c23b06d..1490ed5 100644
--- a/src/ring.h
+++ b/src/ring.h
@@ -65,6 +65,7 @@ struct _VteRing {
VteRowData cached_row;
gulong cached_row_num;
+ gboolean has_streams;
gulong visible_rows_hint; /* to keep at least a screenful of lines in memory, bug 646098 comment 12
*/
};
@@ -78,7 +79,7 @@ struct _VteRing {
const VteRowData *_vte_ring_index (VteRing *ring, gulong position);
VteRowData *_vte_ring_index_writable (VteRing *ring, gulong position);
-void _vte_ring_init (VteRing *ring, gulong max_rows);
+void _vte_ring_init (VteRing *ring, gulong max_rows, gboolean has_streams);
void _vte_ring_fini (VteRing *ring);
void _vte_ring_reset (VteRing *ring);
void _vte_ring_resize (VteRing *ring, gulong max_rows);
diff --git a/src/vte.c b/src/vte.c
index 07508c4..bcd4b21 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -8023,9 +8023,9 @@ vte_terminal_init(VteTerminal *terminal)
/* We allocated zeroed memory, just fill in non-zero stuff. */
/* Initialize the screens and histories. */
- _vte_ring_init (pvt->alternate_screen.row_data, terminal->pvt->row_count);
+ _vte_ring_init (pvt->alternate_screen.row_data, terminal->pvt->row_count, FALSE);
pvt->screen = &terminal->pvt->alternate_screen;
- _vte_ring_init (pvt->normal_screen.row_data, VTE_SCROLLBACK_INIT);
+ _vte_ring_init (pvt->normal_screen.row_data, VTE_SCROLLBACK_INIT, TRUE);
pvt->screen = &terminal->pvt->normal_screen;
_vte_terminal_set_default_attributes(terminal);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]