Changeset: 6e7a9ec2ebbc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6e7a9ec2ebbc
Modified Files:
        sql/common/sql_list.c
        sql/include/sql_list.h
        sql/storage/store.c
Branch: Jul2021
Log Message:

use new list_revert function to revert the list without requiring new 
allocations


diffs (70 lines):

diff --git a/sql/common/sql_list.c b/sql/common/sql_list.c
--- a/sql/common/sql_list.c
+++ b/sql/common/sql_list.c
@@ -441,6 +441,23 @@ list_check_prop_all(list *l, prop_check_
        return res;
 }
 
+void
+list_revert(list *l)
+{
+       node *c = NULL;
+
+       l->t = l->h;
+       for (node *o = l->h; o; ) {
+               node *nxt = o->next;
+
+               o->next = c;
+               c = o;
+
+               o = nxt;
+       }
+       l->h = c;
+}
+
 int
 list_traverse(list *l, traverse_func f, void *clientdata)
 {
diff --git a/sql/include/sql_list.h b/sql/include/sql_list.h
--- a/sql/include/sql_list.h
+++ b/sql/include/sql_list.h
@@ -54,7 +54,7 @@ extern node *list_remove_node(list *l, v
 extern void list_remove_data(list *l, void *gdata, void *data);
 extern void list_remove_list(list *l, void *gdata, list *data);
 extern void list_move_data(list *l, list *d, void *data);
-
+extern void list_revert(list *l);
 
 extern int list_traverse(list *l, traverse_func f, void *clientdata);
 
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -3493,9 +3493,8 @@ sql_trans_rollback(sql_trans *tr, bool c
        }
        if (!list_empty(tr->changes)) {
                /* revert the change list */
-               list *nl = SA_LIST(tr->sa, (fdestroy) NULL);
-               for(node *n=tr->changes->h; n; n = n->next)
-                       list_prepend(nl, n->data);
+               list *nl = tr->changes;
+               list_revert(nl);
 
                /* rollback */
                if (!commit_lock)
@@ -3517,6 +3516,7 @@ sql_trans_rollback(sql_trans *tr, bool c
                        if (!c->cleanup) {
                                _DELETE(c);
                        } else if (c->cleanup && !c->cleanup(store, c, oldest)) 
{
+                               /* TODO change too node stealing (no allocs 
here) */
                                store->changes = sa_list_append(tr->sa, 
store->changes, c);
                        } else
                                _DELETE(c);
@@ -3524,7 +3524,6 @@ sql_trans_rollback(sql_trans *tr, bool c
                store_unlock(store);
                if (!commit_lock)
                        MT_lock_unset(&store->commit);
-               list_destroy(nl);
                list_destroy(tr->changes);
                tr->changes = NULL;
                tr->logchanges = 0;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to