From e72c582ca7881c2f831ee339a54fcf6dc42763af Mon Sep 17 00:00:00 2001 From: divinity76 Date: Sat, 8 Aug 2026 08:37:00 +0200 Subject: [PATCH] Optimize str_repeat The memmove got me thinking "can src and dst actually overlap?", and it turns out no: - e always points to populated data + 1 - l may reach the end of populated data, but will never exceed it memcpy is safe here, and faster (unless the compiler already spotted it in an optimization pass and replaced it internally, entirely possible) --- ext/standard/string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/standard/string.c b/ext/standard/string.c index d8a7479d2a98..0c8abe4c42f3 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -5524,7 +5524,7 @@ PHP_FUNCTION(str_repeat) while (e