summaryrefslogtreecommitdiffstats
path: root/src/gram.y
diff options
context:
space:
mode:
authorAndrés <andmarti@gmail.com>2021-04-01 12:39:53 -0300
committerAndrés <andmarti@gmail.com>2021-04-01 12:39:53 -0300
commit7633c8e177ff19a5ff0ccbfc1c28ac624ac38e06 (patch)
treec829e10c984384f07c8490fc7645d66c1a17444f /src/gram.y
parent78611978eb8bbbc9743dc12615e4f1a38368c38e (diff)
Improve undo / yank using malloc for batches
Diffstat (limited to 'src/gram.y')
-rwxr-xr-xsrc/gram.y23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/gram.y b/src/gram.y
index 7f4f390..5d177c1 100755
--- a/src/gram.y
+++ b/src/gram.y
@@ -417,17 +417,13 @@ command:
{
// TODO get this code out of gram.y
extern graphADT graph;
- #ifdef UNDO
- create_undo_action();
- copy_to_undostruct($2.left.vp->row, $2.left.vp->col, $2.left.vp->row, $2.left.vp->col, UNDO_DEL);
+#ifdef UNDO
// here we save in undostruct, all the ents that depends on the deleted one (before change)
- extern struct ent_ptr * deps;
- int i, n = 0;
ents_that_depends_on_range($2.left.vp->row, $2.left.vp->col, $2.left.vp->row, $2.left.vp->col);
- if (deps != NULL)
- for (i = 0, n = deps->vf; i < n; i++)
- copy_to_undostruct(deps[i].vp->row, deps[i].vp->col, deps[i].vp->row, deps[i].vp->col, UNDO_DEL);
- #endif
+ create_undo_action();
+ copy_to_undostruct($2.left.vp->row, $2.left.vp->col, $2.left.vp->row, $2.left.vp->col, UNDO_DEL, HANDLE_DEPS, NULL);
+#endif
+
if (getVertex(graph, lookat($2.left.vp->row, $2.left.vp->col), 0) != NULL) destroy_vertex(lookat($2.left.vp->row, $2.left.vp->col));
$2.left.vp->v = (double) 0.0;
@@ -444,17 +440,16 @@ command:
if (( $2.left.vp->trigger ) && (($2.left.vp->trigger->flag & TRG_WRITE) == TRG_WRITE))
do_trigger($2.left.vp, TRG_WRITE);
- #ifdef UNDO
- copy_to_undostruct($2.left.vp->row, $2.left.vp->col, $2.left.vp->row, $2.left.vp->col, UNDO_ADD);
+#ifdef UNDO
// here we save in undostruct, all the ents that depends on the deleted one (after change)
+ copy_to_undostruct($2.left.vp->row, $2.left.vp->col, $2.left.vp->row, $2.left.vp->col, UNDO_ADD, HANDLE_DEPS, NULL);
+ extern struct ent_ptr * deps;
if (deps != NULL) {
- for (i = 0, n = deps->vf; i < n; i++)
- copy_to_undostruct(deps[i].vp->row, deps[i].vp->col, deps[i].vp->row, deps[i].vp->col, UNDO_ADD);
free(deps);
deps = NULL;
}
end_undo_action();
- #endif
+#endif
}
| S_LABEL var_or_range '=' e { slet($2.left.vp, $4, 0); }