<commit_before>#include "types.h"
#include "mist32.h"

void*
memset(void *dst, int c, uint n)
{
  unsigned int i;

  if ((int)dst%4 == 0 && n%4 == 0){
    c &= 0xFF;
    for(i = 0; i < n/4; i++) {
      *((int *)dst + i) = (c<<24)|(c<<16)|(c<<8)|c;
    }
  } else {
    for(i = 0; i < n; i++) {
      *((char *)dst + i) = c;
    }
  }
  return dst;
}

int
memcmp(const void *v1, const void *v2, uint n)
{
  const uchar *s1, *s2;
  
  s1 = v1;
  s2 = v2;
  while(n-- > 0){
    if(*s1 != *s2)
      return *s1 - *s2;
    s1++, s2++;
  }

  return 0;
}

void*
memmove(void *dst, const void *src, uint n)
{
  const char *s;
  char *d;

  s = src;
  d = dst;
  if(s < d && s + n > d){
    s += n;
    d += n;
    while(n-- > 0)
      *--d = *--s;
  } else
    while(n-- > 0)
      *d++ = *s++;
<commit_msg>fast memmove<commit_after>#include "types.h"
#include "mist32.h"

void*
memset(void *dst, int c, uint n)
{
  unsigned int i;

  if ((int)dst%4 == 0 && n%4 == 0){
    c &= 0xFF;
    for(i = 0; i < n/4; i++) {
      *((int *)dst + i) = (c<<24)|(c<<16)|(c<<8)|c;
    }
  } else {
    for(i = 0; i < n; i++) {
      *((char *)dst + i) = c;
    }
  }
  return dst;
}

int
memcmp(const void *v1, const void *v2, uint n)
{
  const uchar *s1, *s2;
  
  s1 = v1;
  s2 = v2;
  while(n-- > 0){
    if(*s1 != *s2)
      return *s1 - *s2;
    s1++, s2++;
  }

  return 0;
}

void*
memmove(void *dst, const void *src, uint n)
{
  const char *s;
  char *d;

  s = src;
  d = dst;
  if(s < d && s + n > d){
    s += n;
    d += n;
    while(n-- > 0)
      *--d = *--s;
  } else if((int)s&3 || (int)d&3 || n&3)
    while(n-- > 0)
      *d++ = *s++;
  else {
    const uint *ss = (const uint *)s;
    uint *dd = (uint *)d;
    while(n > 0) {
      n-=4;
      *dd++ = *ss++;
    }
  }

{'fraction_non_alphanumeric': 0.2403846153846154, 'fraction_numerical': 0.040158371040723985, 'mean_word_length': 1.8440514469453375, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4450110', 'n_tokens_mistral': 890, 'n_tokens_neox': 852, 'n_words': 230}