From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 4DDDE2BB64 for ; Tue, 3 Apr 2018 11:34:21 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AyGJkEOIftUD for ; Tue, 3 Apr 2018 11:34:21 -0400 (EDT) Received: from smtp58.i.mail.ru (smtp58.i.mail.ru [217.69.128.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 057F72BB85 for ; Tue, 3 Apr 2018 11:34:21 -0400 (EDT) From: Vladislav Shpilevoy Subject: [tarantool-patches] [PATCH 4/4] sql: remove useless branching in insertOrReplace Date: Tue, 3 Apr 2018 18:34:15 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: korablev@tarantool.org, Vladislav Shpilevoy 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)