Commit f40a84cd61e for php

commit f40a84cd61efdbaf8a6cf9eaaf354521238d84f0
Author: divinity76 <divinity76@gmail.com>
Date:   Sun Oct 18 11:31:25 2026 +0200

    Optimize str_repeat (#23128)

    * 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)

    * comment pinning the non-overlap invariant

    Co-authored-by: Xinchen Hui <laruence@gmail.com>

    ---------

    Co-authored-by: Xinchen Hui <laruence@gmail.com>

diff --git a/ext/standard/string.c b/ext/standard/string.c
index 2e949da741d..3775074b590 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -5664,7 +5664,8 @@ PHP_FUNCTION(str_repeat)

 		while (e<ee) {
 			l = (e-s) < (ee-e) ? (e-s) : (ee-e);
-			memmove(e, s, l);
+			/* src [s, s+l) and dst [e, e+l) cannot overlap: l <= e-s */
+			memcpy(e, s, l);
 			e += l;
 		}
 	}