[tarantool-patches] Re: [PATCH v1 1/1] sql: drop useless legacy Cursor hints
Kirill Shcherbatov
kshcherbatov at tarantool.org
Wed Jun 20 09:58:32 MSK 2018
>> Deleted BTREE_BULKLOAD and OPFLAG_BULKCSR as there become
>
> Typo: there —> they.
Ok, fixed.
> Except for your removals, I also suggest you to remove:
>
> SQLITE_CursorHints macros;
> sqlite3CursorHintFlags() function — it is used only once and can be inlined;
> sqlite3CursorHasHint() function — it is used only once and can be inlined;
Thank you for suggestion,
diff --git a/src/box/sql/cursor.c b/src/box/sql/cursor.c
index 9dd2b02..b096691 100644
--- a/src/box/sql/cursor.c
+++ b/src/box/sql/cursor.c
@@ -48,16 +48,6 @@ sql_cursor_cleanup(struct BtCursor *cursor)
}
/*
- * Provide flag hints to the cursor.
- */
-void
-sqlite3CursorHintFlags(BtCursor * pCur, unsigned x)
-{
- assert(x == OPFLAG_SEEKEQ || x == 0);
- pCur->hints = x;
-}
-
-/*
* Initialize memory that will be converted into a BtCursor object.
*/
void
@@ -185,13 +175,3 @@ sqlite3CursorPrevious(BtCursor *pCur, int *pRes)
*pRes = 0;
return tarantoolSqlite3Previous(pCur, pRes);
}
-
-/*
- * Return true if the cursor has a hint specified. This routine is
- * only used from within assert() statements
- */
-int
-sqlite3CursorHasHint(BtCursor *pCsr, unsigned int mask)
-{
- return (pCsr->hints & mask) != 0;
-}
diff --git a/src/box/sql/cursor.h b/src/box/sql/cursor.h
index 252aaac..da711a7 100644
--- a/src/box/sql/cursor.h
+++ b/src/box/sql/cursor.h
@@ -54,7 +54,6 @@ struct BtCursor {
};
void sqlite3CursorZero(BtCursor *);
-void sqlite3CursorHintFlags(BtCursor *, unsigned);
/**
* Close a cursor and invalidate its state. In case of
@@ -76,7 +75,6 @@ int sqlite3CursorPayload(BtCursor *, u32 offset, u32 amt, void *);
*/
void
sql_cursor_cleanup(struct BtCursor *cursor);
-int sqlite3CursorHasHint(BtCursor *, unsigned int mask);
#ifndef NDEBUG
int sqlite3CursorIsValid(BtCursor *);
diff --git a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h
index 272d95e..956d6fc 100644
--- a/src/box/sql/sqliteInt.h
+++ b/src/box/sql/sqliteInt.h
@@ -1696,7 +1696,6 @@ struct sqlite3 {
#define SQLITE_SubqCoroutine 0x0100 /* Evaluate subqueries as coroutines */
#define SQLITE_Transitive 0x0200 /* Transitive constraints */
#define SQLITE_OmitNoopJoin 0x0400 /* Omit unused tables in joins */
-#define SQLITE_CursorHints 0x2000 /* Add OP_CursorHint opcodes */
#define SQLITE_AllOpts 0xffff /* All optimizations */
/*
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index 3139933..e1265f4 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -3206,7 +3206,7 @@ case OP_OpenWrite:
pCur->key_def = index->def->key_def;
open_cursor_set_hints:
- sqlite3CursorHintFlags(pCur->uc.pCursor, pOp->p5 & OPFLAG_SEEKEQ);
+ pCur->uc.pCursor->hints = pOp->p5 & OPFLAG_SEEKEQ;
if (rc) goto abort_due_to_error;
break;
}
@@ -3526,7 +3526,7 @@ case OP_SeekGT: { /* jump, in3 */
* must be immediately followed by an OP_IdxGT or
* OP_IdxLT opcode, respectively, with the same key.
*/
- if (sqlite3CursorHasHint(pC->uc.pCursor, OPFLAG_SEEKEQ) != 0) {
+ if ((pC->uc.pCursor->hints & OPFLAG_SEEKEQ) != 0) {
eqOnly = 1;
assert(pOp->opcode==OP_SeekGE || pOp->opcode==OP_SeekLE);
assert(pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT);
More information about the Tarantool-patches
mailing list