<commit_before>﻿#region Using

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using String = Messages.std_msgs.String;

#endregion

namespace Messages
{
    [System.Diagnostics.DebuggerStepThrough]
    [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
    public static class SerializationHelper
    {
        private static bool WHAT_IS_HAPPENING;
        public static void ShowDeserializationSteps()
        {
            WHAT_IS_HAPPENING = true;
        }

        static Dictionary<Type, MsgTypes> GetMessageTypeMemo = new Dictionary<Type, MsgTypes>();
        //[DebuggerStepThrough]
        public static MsgTypes GetMessageType(Type t)
        {
            MsgTypes mt;
            //gross, but it gets the job done   
            lock (GetMessageTypeMemo)
            {
                if (t == typeof(Boolean) && !GetMessageTypeMemo.ContainsKey(t))  //ERIC
                    GetMessageTypeMemo.Add(t, (MsgTypes)Enum.Parse(typeof(MsgTypes), "std_msgs__Bool")); //ERIC
                if (GetMessageTypeMemo.ContainsKey(t))
                    return GetMessageTypeMemo[t];
                mt = GetMessageType(t.FullName);
                GetMessageTypeMemo.Add(t, mt);
            }
            return mt;
        }

        //[DebuggerStepThrough]
        public static Type GetType(string s)
        {
            Type ret;
            MsgTypes mt = GetMessageType(s);
            if (mt == MsgTypes.Unknown)
                ret = Type.GetType(s, true, true);
            else
                ret = IRosMessage.generate(mt).GetType();
            //            Console.WriteLine(s + "=" + ret.Name);
            return ret;
        }

        static Dictionary<string, MsgTypes> GetMessageTypeMemoString = new Dictionary<string, MsgTypes>();

        //[DebuggerStepThrough]
        public static MsgTypes GetMessageType(string s)
        {
            //Console.WriteLine("LOOKING FOR: " + s + "'s type");
            lock (GetMessageTypeMemoString)
            {
                if (GetMessageTypeMemoString.ContainsKey(s))
                    return GetMessageTypeMemoString[s];
                if (s.Contains("TimeData"))
                {<commit_msg>GetMessageTypeMemo: only lock if we need to add to the dict<commit_after>﻿#region Using

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using String = Messages.std_msgs.String;

#endregion

namespace Messages
{
    [System.Diagnostics.DebuggerStepThrough]
    [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
    public static class SerializationHelper
    {
        private static bool WHAT_IS_HAPPENING;
        public static void ShowDeserializationSteps()
        {
            WHAT_IS_HAPPENING = true;
        }

        static Dictionary<Type, MsgTypes> GetMessageTypeMemo = new Dictionary<Type, MsgTypes>();
        //[DebuggerStepThrough]
        public static MsgTypes GetMessageType(Type t)
        {
            MsgTypes mt;
            //gross, but it gets the job done   
            if (t == typeof(Boolean) && !GetMessageTypeMemo.ContainsKey(t))  //ERIC
                lock (GetMessageTypeMemo)
                {
                    if (!GetMessageTypeMemo.ContainsKey(t))
                        GetMessageTypeMemo.Add(t, (MsgTypes) Enum.Parse(typeof (MsgTypes), "std_msgs__Bool")); //ERIC
                }
            if (GetMessageTypeMemo.ContainsKey(t))
                return GetMessageTypeMemo[t];
            lock (GetMessageTypeMemo)
            {
                if (GetMessageTypeMemo.ContainsKey(t))
                    return GetMessageTypeMemo[t];
                mt = GetMessageType(t.FullName);
                GetMessageTypeMemo.Add(t, mt);
                return mt;
            }
        }

        //[DebuggerStepThrough]
        public static Type GetType(string s)
        {
            Type ret;
            MsgTypes mt = GetMessageType(s);
            if (mt == MsgTypes.Unknown)
                ret = Type.GetType(s, true, true);
            else
                ret = IRosMessage.generate(mt).GetType();
            //            Console.WriteLine(s + "=" + ret.Name);
            return ret;
        }

        static Dictionary<string, MsgTypes> GetMessageTypeMemoString = new Dictionary<string, MsgTypes>();

        //[DebuggerStepThrough]
        public static MsgTypes GetMessageType(string s)
        {
            //Console.WriteLine("LOOKING FOR: " + s + "'s type");
            lock (GetMessageTypeMemoString)
            {
                if (GetMessageTypeMemoString.ContainsKey(s))
                    return GetMessageTypeMemoString[s];
                if (s.Contains("TimeData"))
                {
{'fraction_non_alphanumeric': 0.09209744503862151, 'fraction_numerical': 0.0, 'mean_word_length': 1.975839717147908, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2644598', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1360, 'n_words': 292}