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 7FA862C0F5 for ; Tue, 3 Apr 2018 19:01:49 -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 2a18h9BEan7u for ; Tue, 3 Apr 2018 19:01:49 -0400 (EDT) Received: from smtp33.i.mail.ru (smtp33.i.mail.ru [94.100.177.93]) (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 3F5822C0B9 for ; Tue, 3 Apr 2018 19:01:49 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [tarantool-patches] Re: [PATCH 4/4] sql: remove useless branching in insertOrReplace From: "n.pettik" In-Reply-To: Date: Wed, 4 Apr 2018 02:01:46 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: 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: Vladislav Shpilevoy Cc: tarantool-patches@freelists.org Ack. > On 3 Apr 2018, at 18:34, Vladislav Shpilevoy = wrote: >=20 > 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(-) >=20 > 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; > } >=20 > -static int insertOrReplace(BtCursor *pCur, int operationType) > +static inline int > +insertOrReplace(BtCursor *pCur, enum iproto_type type) > { > assert(pCur->curFlags & BTCF_TaCursor); > - assert(operationType =3D=3D TARANTOOL_INDEX_INSERT || > - operationType =3D=3D TARANTOOL_INDEX_REPLACE); > - > struct request request; > memset(&request, 0, sizeof(request)); > request.tuple =3D pCur->key; > request.tuple_end =3D pCur->key + pCur->nKey; > request.space_id =3D pCur->space->def->id; > + request.type =3D type; > mp_tuple_assert(request.tuple, request.tuple_end); > - if (operationType =3D=3D TARANTOOL_INDEX_INSERT) { > - request.type =3D IPROTO_INSERT; > - } else { > - request.type =3D IPROTO_REPLACE; > - } > int rc =3D box_process_rw(&request, pCur->space, NULL); > - return rc =3D=3D 0 ? SQLITE_OK : SQL_TARANTOOL_INSERT_FAIL;; > + return rc =3D=3D 0 ? SQLITE_OK : SQL_TARANTOOL_INSERT_FAIL; > } >=20 > int tarantoolSqlite3Insert(BtCursor *pCur) > { > - return insertOrReplace(pCur, TARANTOOL_INDEX_INSERT); > + return insertOrReplace(pCur, IPROTO_INSERT); > } >=20 > int tarantoolSqlite3Replace(BtCursor *pCur) > { > - return insertOrReplace(pCur, TARANTOOL_INDEX_REPLACE); > + return insertOrReplace(pCur, IPROTO_REPLACE); > } >=20 > /* > --=20 > 2.14.3 (Apple Git-98) >=20 >=20