Repository navigation
Commit f40a84c
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>1 parent a8bbfb8 commit f40a84c
1 file changed
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5664 | 5664 | | |
5665 | 5665 | | |
5666 | 5666 | | |
5667 | | - | |
| 5667 | + | |
| 5668 | + | |
5668 | 5669 | | |
5669 | 5670 | | |
5670 | 5671 | | |
| |||
0 commit comments