<commit_before>using System;
using System.IO;

namespace Wire.ValueSerializers
{
    public class DateTimeSerializer : SessionAwareValueSerializer<DateTime>
    {
        public const byte Manifest = 5;
        public const int Size = sizeof(long);
        public static readonly DateTimeSerializer Instance = new DateTimeSerializer();

        public DateTimeSerializer() : base(Manifest, () => WriteValueImpl)
        {
        }

        static void WriteValueImpl(Stream stream, DateTime dateTime, SerializerSession session)
        {
            var bytes = NoAllocBitConverter.GetBytes(dateTime.Ticks, session);
            stream.Write(bytes, 0, Size);
            var kindByte = (byte) dateTime.Kind;
            stream.WriteByte(kindByte);
        }

        public override object ReadValue(Stream stream, DeserializerSession session)
        {
            var buffer = session.GetBuffer(Size);
            stream.Read(buffer, 0, Size);
            var ticks = BitConverter.ToInt64(buffer, 0);
            var kind = (DateTimeKind) stream.ReadByte();
            var dateTime = new DateTime(ticks, kind);
            return dateTime;
        }
    }
}<commit_msg>faster datetime<commit_after>using System;
using System.IO;

namespace Wire.ValueSerializers
{
    public class DateTimeSerializer : SessionAwareValueSerializer<DateTime>
    {
        public const byte Manifest = 5;
        public const int Size = sizeof(long);
        public static readonly DateTimeSerializer Instance = new DateTimeSerializer();

        public DateTimeSerializer() : base(Manifest, () => WriteValueImpl)
        {
        }

        static void WriteValueImpl(Stream stream, DateTime dateTime, SerializerSession session)
        {
            var bytes = NoAllocBitConverter.GetBytes(dateTime.Ticks, session);
            stream.Write(bytes, 0, Size);
            var kindByte = (byte) dateTime.Kind;
            stream.WriteByte(kindByte);
        }

        public override object ReadValue(Stream stream, DeserializerSession session)
        {
            var buffer = session.GetBuffer(Size+1);
            stream.Read(buffer, 0, Size+1);
            var ticks = BitConverter.ToInt64(buffer, 0);
            var kind = (DateTimeKind) buffer[Size]; //avoid reading a single byte from the stream
            var dateTime = new DateTime(ticks, kind);
            return dateTime;
        }
    }
}
{'fraction_non_alphanumeric': 0.08399498537400753, 'fraction_numerical': 0.0058503969912244045, 'mean_word_length': 2.424892703862661, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6529676', 'n_tokens_mistral': 608, 'n_tokens_neox': 590, 'n_words': 167}