svn commit: samba r7343 - in branches/SAMBA_4_0/source/lib/ldb/ldb_sqlite3: .

derrell at samba.org derrell at samba.org
Mon Jun 6 17:04:34 GMT 2005


idra at samba.org writes:

>          /* Skip protocol indicator of url  */
> -        if ((p = strchr(url, ':')) == NULL) {
> -                return SQLITE_MISUSE;
> -        } else {
> -                ++p;
> -        }
> +	if (strchr(url, ':')) {
> +		if (strncmp(url, "sqlite://", 9) != 0) {
> +			errno = EINVAL;
> +			return SQLITE_MISUSE;
> +		}
> +		p = url + 9;
> +	} else {
> +		p = url;
> +	}
> +

Simo, I believe this is a waste.  We can't (or at least, shouldn't be able to)
get here (into ldb_sqlite3) without the url having a proper protocol
indicator.  Your new method scans the string twice (once in strchr() and again
in strncmp(), unnecessarily I think.  If it is possible to get here with a
protocol indicator other than the intended one, the higher-level (calling)
code should be fixed to ensure that can not happen.  Then, the code I had
intentionally replaced the tdb code with (pre- this change) is more efficient.

Cheers,

Derrell


More information about the samba-technical mailing list