From 1210648e46b9a3682e7ba279643e175987d83a38 Mon Sep 17 00:00:00 2001
From: Aleksandr Lyapunov <alyapunov@tarantool.org>
Date: Fri, 25 Dec 2020 08:34:05 +0300
Subject: [PATCH] txm: code reorder

Part of #5628
---
 src/box/memtx_tx.c | 87 ++++++++++++++++++++++------------------------
 1 file changed, 42 insertions(+), 45 deletions(-)

diff --git a/src/box/memtx_tx.c b/src/box/memtx_tx.c
index 7697f632e5..c5c19cae85 100644
--- a/src/box/memtx_tx.c
+++ b/src/box/memtx_tx.c
@@ -235,7 +235,48 @@ memtx_tx_story_new(struct space *space, struct tuple *tuple)
 }
 
 static void
-memtx_tx_story_delete(struct memtx_story *story);
+memtx_tx_story_delete(struct memtx_story *story)
+{
+	assert(story->add_stmt == NULL);
+	assert(story->del_stmt == NULL);
+
+	if (txm.traverse_all_stories == &story->in_all_stories)
+		txm.traverse_all_stories = rlist_next(txm.traverse_all_stories);
+	rlist_del(&story->in_all_stories);
+	rlist_del(&story->in_space_stories);
+
+	mh_int_t pos = mh_history_find(txm.history, story->tuple, 0);
+	assert(pos != mh_end(txm.history));
+	mh_history_del(txm.history, pos, 0);
+
+	story->tuple->is_dirty = false;
+	tuple_unref(story->tuple);
+
+#ifndef NDEBUG
+	/* Expecting to delete fully unlinked story. */
+	for (uint32_t i = 0; i < story->index_count; i++) {
+		assert(story->link[i].newer_story == NULL);
+		assert(story->link[i].older.is_story == false);
+		assert(story->link[i].older.tuple == NULL);
+	}
+#endif
+
+	struct mempool *pool = &txm.memtx_tx_story_pool[story->index_count];
+	mempool_free(pool, story);
+}
+
+/**
+ * Find a story of a @a tuple. The story expected to be present (assert).
+ */
+static struct memtx_story *
+memtx_tx_story_get(struct tuple *tuple)
+{
+	assert(tuple->is_dirty);
+
+	mh_int_t pos = mh_history_find(txm.history, tuple, 0);
+	assert(pos != mh_end(txm.history));
+	return *mh_history_node(txm.history, pos);
+}
 
 /**
  * Create a new story of a @a tuple that was added by @a stmt.
@@ -292,19 +333,6 @@ memtx_tx_story_delete_del_stmt(struct memtx_story *story)
 }
 
 
-/**
- * Find a story of a @a tuple. The story expected to be present (assert).
- */
-static struct memtx_story *
-memtx_tx_story_get(struct tuple *tuple)
-{
-	assert(tuple->is_dirty);
-
-	mh_int_t pos = mh_history_find(txm.history, tuple, 0);
-	assert(pos != mh_end(txm.history));
-	return *mh_history_node(txm.history, pos);
-}
-
 /**
  * Get the older tuple, extracting it from older story if necessary.
  */
@@ -1098,37 +1126,6 @@ memtx_tx_on_space_delete(struct space *space)
 	}
 }
 
-static void
-memtx_tx_story_delete(struct memtx_story *story)
-{
-	assert(story->add_stmt == NULL);
-	assert(story->del_stmt == NULL);
-
-	if (txm.traverse_all_stories == &story->in_all_stories)
-		txm.traverse_all_stories = rlist_next(txm.traverse_all_stories);
-	rlist_del(&story->in_all_stories);
-	rlist_del(&story->in_space_stories);
-
-	mh_int_t pos = mh_history_find(txm.history, story->tuple, 0);
-	assert(pos != mh_end(txm.history));
-	mh_history_del(txm.history, pos, 0);
-
-	story->tuple->is_dirty = false;
-	tuple_unref(story->tuple);
-
-#ifndef NDEBUG
-	/* Expecting to delete fully unlinked story. */
-	for (uint32_t i = 0; i < story->index_count; i++) {
-		assert(story->link[i].newer_story == NULL);
-		assert(story->link[i].older.is_story == false);
-		assert(story->link[i].older.tuple == NULL);
-	}
-#endif
-
-	struct mempool *pool = &txm.memtx_tx_story_pool[story->index_count];
-	mempool_free(pool, story);
-}
-
 int
 memtx_tx_track_read(struct txn *txn, struct space *space, struct tuple *tuple)
 {
-- 
GitLab