Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: korablev@tarantool.org, Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Subject: [tarantool-patches] [PATCH 4/4] sql: remove useless branching in insertOrReplace
Date: Tue,  3 Apr 2018 18:34:15 +0300	[thread overview]
Message-ID: <e022dc159618039cd3e1edb064b153935da64122.1522769319.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1522769319.git.v.shpilevoy@tarantool.org>
In-Reply-To: <cover.1522769319.git.v.shpilevoy@tarantool.org>

Type of an operation for struct request can be passed directly
with no "proxying" by special codes.
---
 src/box/sql.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/box/sql.c b/src/box/sql.c
index c2577abef..a6713f1f0 100644
--- a/src/box/sql.c
+++ b/src/box/sql.c
@@ -474,35 +474,29 @@ int tarantoolSqlite3EphemeralDrop(BtCursor *pCur)
 	return SQLITE_OK;
 }
 
-static int insertOrReplace(BtCursor *pCur, int operationType)
+static inline int
+insertOrReplace(BtCursor *pCur, enum iproto_type type)
 {
 	assert(pCur->curFlags & BTCF_TaCursor);
-	assert(operationType == TARANTOOL_INDEX_INSERT ||
-	       operationType == TARANTOOL_INDEX_REPLACE);
-
 	struct request request;
 	memset(&request, 0, sizeof(request));
 	request.tuple = pCur->key;
 	request.tuple_end = pCur->key + pCur->nKey;
 	request.space_id = pCur->space->def->id;
+	request.type = type;
 	mp_tuple_assert(request.tuple, request.tuple_end);
-	if (operationType == TARANTOOL_INDEX_INSERT) {
-		request.type = IPROTO_INSERT;
-	} else {
-		request.type = IPROTO_REPLACE;
-	}
 	int rc = box_process_rw(&request, pCur->space, NULL);
-	return rc == 0 ? SQLITE_OK : SQL_TARANTOOL_INSERT_FAIL;;
+	return rc == 0 ? SQLITE_OK : SQL_TARANTOOL_INSERT_FAIL;
 }
 
 int tarantoolSqlite3Insert(BtCursor *pCur)
 {
-	return insertOrReplace(pCur, TARANTOOL_INDEX_INSERT);
+	return insertOrReplace(pCur, IPROTO_INSERT);
 }
 
 int tarantoolSqlite3Replace(BtCursor *pCur)
 {
-	return insertOrReplace(pCur, TARANTOOL_INDEX_REPLACE);
+	return insertOrReplace(pCur, IPROTO_REPLACE);
 }
 
 /*
-- 
2.14.3 (Apple Git-98)

  parent reply	other threads:[~2018-04-03 15:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-03 15:34 [tarantool-patches] [PATCH 0/4] sql: refactor insertion and lua Vladislav Shpilevoy
2018-04-03 15:34 ` [tarantool-patches] [PATCH 1/4] sql: remove unused opcodes from OP_[Sorter/Idx][Insert/Replace] Vladislav Shpilevoy
2018-04-03 23:01   ` [tarantool-patches] " n.pettik
2018-04-04 10:26     ` Vladislav Shpilevoy
2018-04-04 11:51       ` n.pettik
2018-04-04 14:48         ` n.pettik
2018-04-03 15:34 ` [tarantool-patches] [PATCH 2/4] sql: remove unused error codes, use enum instead of defines Vladislav Shpilevoy
2018-04-03 23:01   ` [tarantool-patches] " n.pettik
2018-04-04 10:26     ` Vladislav Shpilevoy
2018-04-04 11:30       ` n.pettik
2018-04-03 15:34 ` [tarantool-patches] [PATCH 3/4] sql: simplify lua SQL executor Vladislav Shpilevoy
2018-04-03 23:02   ` [tarantool-patches] " n.pettik
2018-04-03 15:34 ` Vladislav Shpilevoy [this message]
2018-04-03 23:01   ` [tarantool-patches] Re: [PATCH 4/4] sql: remove useless branching in insertOrReplace n.pettik
2018-04-05 11:43 ` [tarantool-patches] Re: [PATCH 0/4] sql: refactor insertion and lua Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e022dc159618039cd3e1edb064b153935da64122.1522769319.git.v.shpilevoy@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH 4/4] sql: remove useless branching in insertOrReplace' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox