com php-src: avoid strlen usage in the loop: ext/pgsql/pgsql.c

From: Date: Sun, 14 Sep 2014 22:39:55 +0000
Subject: com php-src: avoid strlen usage in the loop: ext/pgsql/pgsql.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-81611@lists.php.net to get a copy of this message
Commit: 32c46f44a808c792b98b1b222dca43d7a6d4c864 Author: Anatol Belski <ab@php.net> Mon, 15 Sep 2014 00:39:55 +0200 Parents: 9873cc29c1b105656c01070663f269f5d6f9b8c3 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=32c46f44a808c792b98b1b222dca43d7a6d4c864 Log: avoid strlen usage in the loop Changed paths: M ext/pgsql/pgsql.c Diff: diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index e3f64e0..e06ca1c 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -5484,26 +5484,26 @@ PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, z char *name; array_init(&elem); /* pg_attribute.attnum */ - add_assoc_long(&elem, "num", atoi(PQgetvalue(pg_result,i,1))); + add_assoc_long_ex(&elem, "num", sizeof("num") - 1, atoi(PQgetvalue(pg_result, i, 1))); /* pg_type.typname */ - add_assoc_string(&elem, "type", PQgetvalue(pg_result,i,2)); + add_assoc_string_ex(&elem, "type", sizeof("type") - 1, PQgetvalue(pg_result, i, 2)); /* pg_attribute.attlen */ - add_assoc_long(&elem, "len", atoi(PQgetvalue(pg_result,i,3))); + add_assoc_long_ex(&elem, "len", sizeof("len") - 1, atoi(PQgetvalue(pg_result,i,3))); /* pg_attribute.attnonull */ - add_assoc_bool(&elem, "not null", !strcmp(PQgetvalue(pg_result,i,4), "t")); + add_assoc_bool_ex(&elem, "not null", sizeof("not null") - 1, !strcmp(PQgetvalue(pg_result, i, 4), "t")); /* pg_attribute..atthasdef */ - add_assoc_bool(&elem, "has default", !strcmp(PQgetvalue(pg_result,i,5), "t")); + add_assoc_bool_ex(&elem, "has default", sizeof("has default") - 1, !strcmp(PQgetvalue(pg_result,i,5), "t")); /* pg_attribute.attndims */ - add_assoc_long(&elem, "array dims", atoi(PQgetvalue(pg_result,i,6))); + add_assoc_long_ex(&elem, "array dims", sizeof("array dims") - 1, atoi(PQgetvalue(pg_result, i, 6))); /* pg_type.typtype */ - add_assoc_bool(&elem, "is enum", !strcmp(PQgetvalue(pg_result,i,7), "e")); + add_assoc_bool_ex(&elem, "is enum", sizeof("is enum") - 1, !strcmp(PQgetvalue(pg_result, i, 7), "e")); if (extended) { /* pg_type.typtype */ - add_assoc_bool(&elem, "is base", !strcmp(PQgetvalue(pg_result,i,7), "b")); - add_assoc_bool(&elem, "is composite", !strcmp(PQgetvalue(pg_result,i,7), "c")); - add_assoc_bool(&elem, "is pesudo", !strcmp(PQgetvalue(pg_result,i,7), "p")); + add_assoc_bool_ex(&elem, "is base", sizeof("is base") - 1, !strcmp(PQgetvalue(pg_result, i, 7), "b")); + add_assoc_bool_ex(&elem, "is composite", sizeof("is composite") - 1, !strcmp(PQgetvalue(pg_result, i, 7), "c")); + add_assoc_bool_ex(&elem, "is pesudo", sizeof("is pesudo") - 1, !strcmp(PQgetvalue(pg_result, i, 7), "p")); /* pg_description.description */ - add_assoc_string(&elem, "description", PQgetvalue(pg_result,i,8)); + add_assoc_string_ex(&elem, "description", sizeof("description") - 1, PQgetvalue(pg_result, i, 8)); } /* pg_attribute.attname */ name = PQgetvalue(pg_result,i,0);

« previous php.cvs (#81611) next »