From d2bc9d4b61e98f4053872f90692dfccbf1202e8a Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Sun, 8 Dec 2024 19:04:56 +0000 Subject: [PATCH] tds: Avoids a call to strlen in tds_submit_rpc tds_put_string can compute the length for us. In other places we use that computation other times so it's worth keeping. Signed-off-by: Frediano Ziglio --- src/tds/query.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/tds/query.c b/src/tds/query.c index d2e612e56..a3145f92c 100644 --- a/src/tds/query.c +++ b/src/tds/query.c @@ -1977,7 +1977,7 @@ TDSRET tds_submit_rpc(TDSSOCKET * tds, const char *rpc_name, TDSPARAMINFO * params, TDSHEADERS * head) { TDSCOLUMN *param; - int rpc_name_len, i; + int i; int num_params = params ? params->num_cols : 0; CHECK_TDS_EXTRA(tds); @@ -1993,14 +1993,13 @@ tds_submit_rpc(TDSSOCKET * tds, const char *rpc_name, TDSPARAMINFO * params, TDS /* distinguish from dynamic query */ tds_release_cur_dyn(tds); - rpc_name_len = (int)strlen(rpc_name); if (IS_TDS7_PLUS(tds->conn)) { if (tds_start_query_head(tds, TDS_RPC, head) != TDS_SUCCESS) return TDS_FAIL; /* procedure name */ TDS_START_LEN_USMALLINT(tds) { - tds_put_string(tds, rpc_name, rpc_name_len); + tds_put_string(tds, rpc_name, -1); } TDS_END_LEN_STRING /* @@ -2027,7 +2026,7 @@ tds_submit_rpc(TDSSOCKET * tds, const char *rpc_name, TDSPARAMINFO * params, TDS tds_put_byte(tds, TDS_DBRPC_TOKEN); TDS_START_LEN_USMALLINT(tds) { TDS_START_LEN_TINYINT(tds) { - tds_put_string(tds, rpc_name, rpc_name_len); + tds_put_string(tds, rpc_name, -1); } TDS_END_LEN /* TODO flags */ tds_put_smallint(tds, num_params ? 2 : 0);