~nloomans/inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

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

Liewe Gutter
Details
Message ID
<20200309152642.30449-1-liewegutter@gmail.com>
DKIM signature
pass
Download raw message
Patch: +17 -1
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
Details
Message ID
<3895c094-effb-4b89-b3ae-e81a69cdeb5f@www.fastmail.com>
In-Reply-To
<20200309152642.30449-1-liewegutter@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Pushed, thanks!

To git.sr.ht:~nloomans/libft
   ec9beb4..8457a55  master -> master
Review patch Export thread (mbox)