Skip to content

Commit 32c46f4

Browse files
committed
avoid strlen usage in the loop
1 parent 9873cc2 commit 32c46f4

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

ext/pgsql/pgsql.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5484,26 +5484,26 @@ PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, z
54845484
char *name;
54855485
array_init(&elem);
54865486
/* pg_attribute.attnum */
5487-
add_assoc_long(&elem, "num", atoi(PQgetvalue(pg_result,i,1)));
5487+
add_assoc_long_ex(&elem, "num", sizeof("num") - 1, atoi(PQgetvalue(pg_result, i, 1)));
54885488
/* pg_type.typname */
5489-
add_assoc_string(&elem, "type", PQgetvalue(pg_result,i,2));
5489+
add_assoc_string_ex(&elem, "type", sizeof("type") - 1, PQgetvalue(pg_result, i, 2));
54905490
/* pg_attribute.attlen */
5491-
add_assoc_long(&elem, "len", atoi(PQgetvalue(pg_result,i,3)));
5491+
add_assoc_long_ex(&elem, "len", sizeof("len") - 1, atoi(PQgetvalue(pg_result,i,3)));
54925492
/* pg_attribute.attnonull */
5493-
add_assoc_bool(&elem, "not null", !strcmp(PQgetvalue(pg_result,i,4), "t"));
5493+
add_assoc_bool_ex(&elem, "not null", sizeof("not null") - 1, !strcmp(PQgetvalue(pg_result, i, 4), "t"));
54945494
/* pg_attribute.atthasdef */
5495-
add_assoc_bool(&elem, "has default", !strcmp(PQgetvalue(pg_result,i,5), "t"));
5495+
add_assoc_bool_ex(&elem, "has default", sizeof("has default") - 1, !strcmp(PQgetvalue(pg_result,i,5), "t"));
54965496
/* pg_attribute.attndims */
5497-
add_assoc_long(&elem, "array dims", atoi(PQgetvalue(pg_result,i,6)));
5497+
add_assoc_long_ex(&elem, "array dims", sizeof("array dims") - 1, atoi(PQgetvalue(pg_result, i, 6)));
54985498
/* pg_type.typtype */
5499-
add_assoc_bool(&elem, "is enum", !strcmp(PQgetvalue(pg_result,i,7), "e"));
5499+
add_assoc_bool_ex(&elem, "is enum", sizeof("is enum") - 1, !strcmp(PQgetvalue(pg_result, i, 7), "e"));
55005500
if (extended) {
55015501
/* pg_type.typtype */
5502-
add_assoc_bool(&elem, "is base", !strcmp(PQgetvalue(pg_result,i,7), "b"));
5503-
add_assoc_bool(&elem, "is composite", !strcmp(PQgetvalue(pg_result,i,7), "c"));
5504-
add_assoc_bool(&elem, "is pesudo", !strcmp(PQgetvalue(pg_result,i,7), "p"));
5502+
add_assoc_bool_ex(&elem, "is base", sizeof("is base") - 1, !strcmp(PQgetvalue(pg_result, i, 7), "b"));
5503+
add_assoc_bool_ex(&elem, "is composite", sizeof("is composite") - 1, !strcmp(PQgetvalue(pg_result, i, 7), "c"));
5504+
add_assoc_bool_ex(&elem, "is pesudo", sizeof("is pesudo") - 1, !strcmp(PQgetvalue(pg_result, i, 7), "p"));
55055505
/* pg_description.description */
5506-
add_assoc_string(&elem, "description", PQgetvalue(pg_result,i,8));
5506+
add_assoc_string_ex(&elem, "description", sizeof("description") - 1, PQgetvalue(pg_result, i, 8));
55075507
}
55085508
/* pg_attribute.attname */
55095509
name = PQgetvalue(pg_result,i,0);

0 commit comments

Comments
 (0)