From 27d70a755a6a9e3a682a14975a1a277668799c37 Mon Sep 17 00:00:00 2001
From: Aleksey Demakov <ademakov@gmail.com>
Date: Thu, 12 Jul 2012 18:15:26 +0400
Subject: [PATCH] Fix the order of checking for linear key parts.

---
 mod/box/tree.m | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/mod/box/tree.m b/mod/box/tree.m
index 6e9d673ae3..1dd0e1bc37 100644
--- a/mod/box/tree.m
+++ b/mod/box/tree.m
@@ -819,7 +819,6 @@ tree_iterator_free(struct iterator *iterator)
 @interface DenseTreeIndex: TreeIndex {
 	@public
 	u32 first_field;
-	bool is_linear;
 }
 @end
 
@@ -830,7 +829,6 @@ tree_iterator_free(struct iterator *iterator)
 	@public
 	u32 first_field;
 	u32 first_offset;
-	bool is_linear;
 }
 @end
 
@@ -1210,7 +1208,6 @@ linear_dense_key_node_cmp(const void *key, const void * node, void *arg)
 {
 	[super enable];
 	first_field = find_first_field(key_def);
-	is_linear = key_is_linear(key_def);
 }
 
 - (size_t) node_size
@@ -1220,17 +1217,23 @@ linear_dense_key_node_cmp(const void *key, const void * node, void *arg)
 
 - (tree_cmp_t) node_cmp
 {
-	return is_linear ? linear_dense_node_cmp : dense_node_cmp;
+	return key_is_linear(key_def)
+		? linear_dense_node_cmp
+		: dense_node_cmp;
 }
 
 - (tree_cmp_t) dup_node_cmp
 {
-	return is_linear ? linear_dense_dup_node_cmp : dense_dup_node_cmp;
+	return key_is_linear(key_def)
+		? linear_dense_dup_node_cmp
+		: dense_dup_node_cmp;
 }
 
 - (tree_cmp_t) key_node_cmp
 {
-	return is_linear ? linear_dense_key_node_cmp : dense_key_node_cmp;
+	return key_is_linear(key_def)
+		? linear_dense_key_node_cmp
+		: dense_key_node_cmp;
 }
 
 - (void) fold: (void *) node :(struct tuple *) tuple
@@ -1398,7 +1401,6 @@ linear_fixed_key_node_cmp(const void *key, const void * node, void *arg)
 	[super enable];
 	first_field = find_first_field(key_def);
 	first_offset = find_fixed_offset(space, first_field, 0);
-	is_linear = key_is_linear(key_def);
 }
 
 - (size_t) node_size
@@ -1408,17 +1410,23 @@ linear_fixed_key_node_cmp(const void *key, const void * node, void *arg)
 
 - (tree_cmp_t) node_cmp
 {
-	return is_linear ? linear_fixed_node_cmp : fixed_node_cmp;
+	return key_is_linear(key_def)
+		? linear_fixed_node_cmp
+		: fixed_node_cmp;
 }
 
 - (tree_cmp_t) dup_node_cmp
 {
-	return is_linear ? linear_fixed_dup_node_cmp : fixed_dup_node_cmp;
+	return key_is_linear(key_def)
+		? linear_fixed_dup_node_cmp
+		: fixed_dup_node_cmp;
 }
 
 - (tree_cmp_t) key_node_cmp
 {
-	return is_linear ? linear_fixed_key_node_cmp : fixed_key_node_cmp;
+	return key_is_linear(key_def)
+		? linear_fixed_key_node_cmp
+		: fixed_key_node_cmp;
 }
 
 - (void) fold: (void *) node :(struct tuple *) tuple
-- 
GitLab