aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/qregisters.h
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2016-11-22 16:47:09 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2016-11-22 18:15:21 +0100
commitaf05d382f26c828a45ba39044cf4e514c0fe9cc6 (patch)
treeb4c034401e3c6d33b66b2d5ff1a00cd55f7793c4 /src/qregisters.h
parent813d9b95d2f59d9a2702e2287f8f6965ba1bbf53 (diff)
save some bytes per Q-Register creation on the undo stack
* a table reference was stored in the UndoToken. * since there are only two tables at a given moment, this can be avoided by having two different undo tokens, one for globals and one for locals. * Practically, undo tokens for locals are only created for the top-level local Q-Reg table since macro calls with locals with set must_undo to false since the local table is destroyed with the macro return.
Diffstat (limited to 'src/qregisters.h')
-rw-r--r--src/qregisters.h35
1 files changed, 14 insertions, 21 deletions
diff --git a/src/qregisters.h b/src/qregisters.h
index fc7a624..d40a19b 100644
--- a/src/qregisters.h
+++ b/src/qregisters.h
@@ -285,25 +285,23 @@ public:
};
class QRegisterTable : private RBTreeString, public Object {
- class UndoTokenRemove : public UndoToken {
- /*
- * NOTE: Storing the table here is only necessary since
- * we may have to remove from a global or local Q-Reg
- * table. This could be avoided using a separate
- * subclass for local registers.
- */
- QRegisterTable *table;
+ class UndoTokenRemoveGlobal : public UndoToken {
+ protected:
QRegister *reg;
public:
- UndoTokenRemove(QRegisterTable *_table, QRegister *_reg)
- : table(_table), reg(_reg) {}
+ UndoTokenRemoveGlobal(QRegister *_reg)
+ : reg(_reg) {}
- void
- run(void)
- {
- delete (QRegister *)table->remove(reg);
- }
+ void run(void);
+ };
+
+ class UndoTokenRemoveLocal : public UndoTokenRemoveGlobal {
+ public:
+ UndoTokenRemoveLocal(QRegister *reg)
+ : UndoTokenRemoveGlobal(reg) {}
+
+ void run(void);
};
bool must_undo;
@@ -320,12 +318,7 @@ public:
delete (QRegister *)remove(cur);
}
- inline void
- undo_remove(QRegister *reg)
- {
- if (must_undo)
- undo.push<UndoTokenRemove>(this, reg);
- }
+ void undo_remove(QRegister *reg);
inline QRegister *
insert(QRegister *reg)