<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace FreecraftCore.Serializer.KnownTypes
{
	/*unchecked
{
	fixed (int* intPtr = &value[0])
	{
		//Profiled and this is the fastest solution I could come up with.
		//There isn't a way to directly set the int array to the byte array.

		int size = value.Length * sizeof(int);
		byte* bPtr = (byte*)intPtr;
		byte[] bytes = new byte[size];

		for (int i = 0; i < size; i++)
		{
			bytes[i] = *(bPtr);

			bPtr++;
		}

		dest.Write(bytes);
	}
}*/

	/*public class Int32ArraySerializerDecorator : ArraySerializerDecorator<int>
	{
		public Int32ArraySerializerDecorator(IGeneralSerializerProvider serializerProvider) : base(serializerProvider)
		{

		}

		public unsafe override void Write(int[] value, IWireMemberWriterStrategy dest)
		{
			//Write byte as size
			dest.Write((byte)value.Length);

			//Believe or not this is an order of magnitude faster than the below pointer hacking
			//Even the pointer hacking was like 300% faster than manual writing
			FastArraySerializer.AsByteArray(value, bs => dest.Write(bs));
		}

		public unsafe override int[] Read(IWireMemberReaderStrategy source)
		{
			byte size = source.ReadByte();

			byte[] bytes = source.ReadBytes(size * sizeof(int));

			return FastArraySerializer.AsIntArrayPerm(bytes);
		}
	}

	//Based on hack from: http://stackoverflow.com/questions/619041/what-is-the-fastest-way-to-convert-a-float-to-a-byte
	public static unsafe class FastArraySerializer
	{
		[StructLayout(LayoutKind.Explicit)]
		private struct Union<commit_msg>Fixed commented out exprimental serializer<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace FreecraftCore.Serializer.KnownTypes
{
	/*unchecked
{
	fixed (int* intPtr = &value[0])
	{
		//Profiled and this is the fastest solution I could come up with.
		//There isn't a way to directly set the int array to the byte array.

		int size = value.Length * sizeof(int);
		byte* bPtr = (byte*)intPtr;
		byte[] bytes = new byte[size];

		for (int i = 0; i < size; i++)
		{
			bytes[i] = *(bPtr);

			bPtr++;
		}

		dest.Write(bytes);
	}
}*/

	/*public class Int32ArraySerializerDecorator : ArraySerializerDecorator<int>
	{
		public Int32ArraySerializerDecorator(IGeneralSerializerProvider serializerProvider) : base(serializerProvider, new UnknownSizeCollectionSizeStrategy(), SerializationContextRequirement.Contextless)
		{

		}

		public unsafe override void Write(int[] value, IWireMemberWriterStrategy dest)
		{
			//Write byte as size
			dest.Write((byte)value.Length);

			//Believe or not this is an order of magnitude faster than the below pointer hacking
			//Even the pointer hacking was like 300% faster than manual writing
			FastArraySerializer.AsByteArray(value, bs => dest.Write(bs));
		}

		public unsafe override int[] Read(IWireMemberReaderStrategy source)
		{
			byte size = source.ReadByte();

			byte[] bytes = source.ReadBytes(size * sizeof(int));

			return FastArraySerializer.AsIntArrayPerm(bytes);
		}
	}

	//Based on hack from: http://stackoverflow.com/questions/619041/what-is-the-fastest-way-to-convert-a-float-to-a-byte
	public static unsafe class FastArraySerializer
	{
		[StructLayout(LayoutKind.Explicit)]
		private struct Union
{'fraction_non_alphanumeric': 0.10709158771174275, 'fraction_numerical': 0.008613264427217916, 'mean_word_length': 4.286798179059181, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6894630', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1050, 'n_words': 302}