提交 595ec324 编写于 作者: L li-tao116

Optimize strncat

Inline the strlen function to reduce the cost of function calls.

Issue: #I7L0VO
Test: libctest, benchmark
Signed-off-by: Nlitao <litao@kaihong.com>
Change-Id: I0d80a7c985392ebe860ba0deaa67ad7d093705c1
上级 e932e671
......@@ -2204,6 +2204,7 @@ musl_src_porting_file = [
"src/env/getenv.c",
"src/string/strcasecmp.c",
"src/string/strncasecmp.c",
"src/string/strncat.c",
"src/string/stpncpy.c",
"src/string/strncpy.c",
"src/string/strcspn.c",
......
#include <string.h>
char *strncat(char *restrict d, const char *restrict s, size_t n)
{
char *a = d;
while (*d != 0) d++;
while (n && *s) n--, *d++ = *s++;
*d++ = 0;
return a;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册