~nloomans/inbox

made memset significantly faster for very long strings. v1 APPLIED

Liewe Gutter: 1
 made memset significantly faster for very long strings.

 1 files changed, 17 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~nloomans/inbox/patches/9973/mbox | git am -3
Learn more about email & git

[PATCH] made memset significantly faster for very long strings. Export this patch

Memory will now be set in chunks of the size of an unsigned long long,
until there are less characters left than the chunk size.
---
 src/ft_memset.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/ft_memset.c b/src/ft_memset.c
index 83617b4..7308712 100644
--- a/src/ft_memset.c
+++ b/src/ft_memset.c
@@ -14,9 +14,25 @@

void	*ft_memset(void *b, int c, size_t len)
{
	size_t	i;
	size_t				i;
	size_t				chunk_size;
	unsigned long long	chunk;

	chunk = 0;
	chunk_size = sizeof(unsigned long long);
	i = chunk_size / sizeof(unsigned char);
	while (i > 0)
	{
		chunk <<= 8;
		chunk |= (unsigned long long)(unsigned char)c;
		i--;
	}
	i = 0;
	while (len >= chunk_size && i < (len - chunk_size))
	{
		*(unsigned long long *)&(((unsigned char *)b)[i]) = chunk;
		i += chunk_size;
	}
	while (i < len)
	{
		((unsigned char *)b)[i] = (unsigned char)c;
-- 
2.17.1
Pushed, thanks!

To git.sr.ht:~nloomans/libft
   ec9beb4..8457a55  master -> master