Hello Richard !
Time to time I look at some commits that call my attention like this:
[e47fdb49] <http://www.sqlite.org/src/info/e47fdb493bd76d85> Leaf:
Refactor the fts3ColumnMethod() function so that all branches can be
covered. (user: dan
<http://www.sqlite.org/src/timeline?u=dan&c=2017-04-18+05%3A49%3A23&nd&n=200>,
tags: trunk
<http://www.sqlite.org/src/timeline?r=trunk&nd&c=2017-04-18+05%3A49%3A23&n=200>)
And I can see that there is a usage of magic numbers instead of an enum
on named macro, this at large makes understanding of the source a bit
harder.
Some comments following the magic number could be removed if instead of
magic numbers a named constant was used, with the benefit that a named
constant can be searched to see all places where it is used.
====
switch( iCol-p->nColumn ){
case 0: //>>>>>>>>>>>>>> Instead of '0' a named constant would make
following the code a bit easier
/* The special 'table-name' column */
sqlite3_result_blob(pCtx, &pCsr, sizeof(Fts3Cursor*), SQLITE_TRANSIENT);
sqlite3_result_subtype(pCtx, SQLITE_BLOB);
break;
case 1: //>>>>>>>>>>>>> Magic number
/* The docid column */
sqlite3_result_int64(pCtx, pCsr->iPrevId);
break;
case 2: // >>>>>>>>>>> Magic number
if( pCsr->pExpr ){
sqlite3_result_int64(pCtx, pCsr->iLangid);
break;
}else if( p->zLanguageid==0 ){
sqlite3_result_int(pCtx, 0);
break;
}else{
iCol = p->nColumn;
/* fall-through */
}
default:
/* A user column. Or, if this is a full-table scan, possibly the
** language-id column. Seek the cursor. */
rc = fts3CursorSeek(0, pCsr);
if( rc==SQLITE_OK && sqlite3_data_count(pCsr->pStmt)-1>iCol ){
sqlite3_result_value(pCtx, sqlite3_column_value(pCsr->pStmt, iCol+1));
}
break;
}
====
Cheers !
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users