s3: Simplify tdb_data_is_cstr a bit
authorVolker Lendecke <vl@samba.org>
Wed, 13 Jun 2012 07:48:25 +0000 (09:48 +0200)
committerMichael Adam <obnox@samba.org>
Thu, 14 Jun 2012 14:55:58 +0000 (16:55 +0200)
The original code contained rawmemchr for performance reasons. I
would expect the very common strlen routine to be not much worse
performance-wise than rawmemchr. On top, for me this patch simplifies
the expression a bit.

Signed-off-by: Michael Adam <obnox@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Thu Jun 14 16:55:58 CEST 2012 on sn-devel-104

source3/utils/net_registry_check.c

index 6e455db2d892c2bac8be5413792359ffd79fa47e..58cd9f605497de8b0a240288c0f95a8712261eaa 100644 (file)
@@ -211,7 +211,7 @@ static bool tdb_data_is_cstr(TDB_DATA d) {
        if (tdb_data_is_empty(d) || (d.dptr[d.dsize-1] != '\0')) {
                return false;
        }
-       return strchr((char *)d.dptr, '\0') == (char *)&d.dptr[d.dsize-1];
+       return strlen((char *)d.dptr) == d.dsize-1;
 }
 
 static char* tdb_data_print(TALLOC_CTX *mem_ctx, TDB_DATA d)