From 2d31c1c5f08bbe19faf0e874604517fb67dc5ee7 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Tue, 20 Nov 2012 03:33:06 +0100 Subject: fixed rubout of macro invocations: goto tables and q-registers are allocated on the C++ call stack and configured to not emit undo tokens this introduces additional logic but has the huge advantage that the tables can be freed after the macro invocation. if undo tokens were emitted, the tables had to be kept in the undo stack so they can be restored during rubout. this however would be both complicated and unnecessarily inefficient since the tables would reach their initial state during rubout and be deallocated anyways. * similar (but not strictly necessary optimizations) can be performed for macro invocations * also wrapper Q-Register setting/getting -> will allow a custom "*" register getter (e.g. calculates buffer position on the fly) --- qbuffers.h | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'qbuffers.h') diff --git a/qbuffers.h b/qbuffers.h index 3613c93..fae77f5 100644 --- a/qbuffers.h +++ b/qbuffers.h @@ -31,14 +31,19 @@ gchar *get_absolute_path(const gchar *path); */ class QRegisterData { -public: gint64 integer; +public: typedef void document; document *string; gint dot; - QRegisterData() : integer(0), string(NULL), dot(0) {} + /* + * whether to generate UndoTokens (unnecessary in macro invocations) + */ + bool must_undo; + + QRegisterData() : integer(0), string(NULL), dot(0), must_undo(true) {} virtual ~QRegisterData() { @@ -54,6 +59,23 @@ public: return string; } + virtual gint64 + set_integer(gint64 i) + { + return integer = i; + } + virtual void + undo_set_integer(void) + { + if (must_undo) + undo.push_var(integer); + } + virtual gint64 + get_integer(void) + { + return integer; + } + virtual void set_string(const gchar *str); virtual void undo_set_string(void); virtual gchar *get_string(void); @@ -108,8 +130,18 @@ public: }; class QRegisterTable : public RBTree { + bool must_undo; + public: - QRegisterTable() : RBTree() {} + QRegisterTable(bool _undo = true) : RBTree(), must_undo(_undo) {} + + inline QRegister * + insert(QRegister *reg) + { + reg->must_undo = must_undo; + RBTree::insert(reg); + return reg; + } inline void initialize(const gchar *name) -- cgit v1.2.3