SQLite Forum

doc: prepare.html: nByte performance advantage?
["Compiling An SQL Statement" in the SQLite Documentation][1] says:

> If the caller knows that the supplied string is nul-terminated, then there is a small performance advantage to passing an nByte parameter that is the number of bytes in the input string including the nul-terminator.

Is that true?

I looked at the source code of the sqlite3Prepare() routine in src/prepare.c, and the execution path seems like it'd be the same whether nBytes is -1 or the number of bytes in zSql plus one.

    if( nBytes>=0 && (nBytes==0 || zSql[nBytes-1]!=0) ){
      /* . . . */
      /* Wouldn't either value for nBytes take this path? */

Perhaps I'm missing something.

Anyway: I just noticed that nByte in the documentation should be renamed to nBytes (to match the source code).

  [1]: https://www.sqlite.org/c3ref/prepare.html