[tarantool-patches] Re: [PATCH 4/4] sql: remove useless branching in insertOrReplace
n.pettik
korablev at tarantool.org
Wed Apr 4 02:01:46 MSK 2018
Ack.
> On 3 Apr 2018, at 18:34, Vladislav Shpilevoy <v.shpilevoy at tarantool.org> wrote:
>
> 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)
>
>
More information about the Tarantool-patches
mailing list