From 045c80869d3766004b71481cb865e97ebfd34532 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Thu, 19 Oct 2023 23:29:51 -0700 Subject: [PATCH] Use libc strlen in janet_buffer_push_cstring Platform libc's often contains optimized assembly implementations of strlen, so take advantage of them here instead of doing a naive count. --- src/core/buffer.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/buffer.c b/src/core/buffer.c index 16f20248..aee32e58 100644 --- a/src/core/buffer.c +++ b/src/core/buffer.c @@ -135,8 +135,7 @@ void janet_buffer_extra(JanetBuffer *buffer, int32_t n) { /* Push a cstring to buffer */ void janet_buffer_push_cstring(JanetBuffer *buffer, const char *cstring) { - int32_t len = 0; - while (cstring[len]) ++len; + int32_t len = strlen(cstring); janet_buffer_push_bytes(buffer, (const uint8_t *) cstring, len); }