[vte/wip/egmont/bidi: 106/107] soft_wrapped opti



commit 9c235980d7870690129d729b8ec759e8366e995a
Author: Egmont Koblinger <egmont gmail com>
Date:   Wed May 29 12:14:29 2019 +0200

    soft_wrapped opti

 src/ring.cc     | 21 +++++++++++++++++++++
 src/ring.hh     |  1 +
 src/ringview.cc |  5 +----
 3 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/src/ring.cc b/src/ring.cc
index fc1dd047..66822714 100644
--- a/src/ring.cc
+++ b/src/ring.cc
@@ -618,6 +618,27 @@ Ring::index_safe(row_t position)
         return index(position);
 }
 
+bool
+Ring::is_soft_wrapped(row_t position)
+{
+        const VteRowData *row;
+        RowRecord record;
+
+        if (G_UNLIKELY (position < m_start || position >= m_end - 1 /* bottom row inclusive */))
+                return false;
+
+        if (G_LIKELY (position >= m_writable)) {
+                row = get_writable_index(position);
+                return row->attr.soft_wrapped;
+        }
+
+        /* The row is scrolled out to the stream. Save work by not reading the actual row.
+         * The requested information is readily available in row_stream, too. */
+        if (G_UNLIKELY (!read_row_record(&record, position)))
+                return false;
+        return record.soft_wrapped;
+}
+
 /*
  * Returns the hyperlink idx at the given position.
  *
diff --git a/src/ring.hh b/src/ring.hh
index 831a55da..6f74396e 100644
--- a/src/ring.hh
+++ b/src/ring.hh
@@ -75,6 +75,7 @@ public:
         VteRowData const* index(row_t position); /* const? */
         VteRowData const* index_safe(row_t position);
         VteRowData* index_writable(row_t position);
+        bool is_soft_wrapped(row_t position);
 
         void hyperlink_maybe_gc(row_t increment);
         hyperlink_idx_t get_hyperlink_idx(char const* hyperlink);
diff --git a/src/ringview.cc b/src/ringview.cc
index 7cb69687..26d8fcf5 100644
--- a/src/ringview.cc
+++ b/src/ringview.cc
@@ -191,10 +191,7 @@ void RingView::update()
 
         int i = VTE_RINGVIEW_PARAGRAPH_LENGTH_MAX;
         while (i--) {
-                // FIXME this could be much cheaper, we don't need to read the actual rows (text_stream),
-                // we only need the soft_wrapped flag which is stored in row_stream. Needs method in ring.
-                row_data = m_ring->index_safe(row - 1);
-                if (row_data == nullptr || !row_data->attr.soft_wrapped)
+                if (!m_ring->is_soft_wrapped(row - 1))
                         break;
                 row--;
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]