<commit_before>﻿using DemoInfo.Messages;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DemoInfo.DP.Handler
{
    class GameEventHandler : IMessageParser
    {
        public bool TryApplyMessage(ProtoBuf.IExtensible message, DemoParser parser)
        {
            if (message is CSVCMsg_GameEventList)
            {
				parser.GEH_Descriptors = new Dictionary<int, CSVCMsg_GameEventList.descriptor_t>();

				foreach (var d in ((CSVCMsg_GameEventList)message).descriptors) {
					parser.GEH_Descriptors[d.eventid] = d;
				}

				return true;
            }

			var descriptors = parser.GEH_Descriptors;
			var blindPlayers = parser.GEH_BlindPlayers;

			if (descriptors == null)
				return false;

			var rawEvent = message as CSVCMsg_GameEvent;
			if (rawEvent == null)
				return false;

            var eventDescriptor = descriptors[rawEvent.eventid];

			if (eventDescriptor.name == "round_start")
				parser.RaiseRoundStart();

			if (eventDescriptor.name == "round_announce_match_start")
				parser.RaiseMatchStarted();

			foreach (var d in rawEvent.keys) {
				GetData (d);
			}

			Dictionary<string, object> data;
			switch (eventDescriptor.name) {
			case "weapon_fire":
				data = MapData (eventDescriptor, rawEvent);

				if (parser.Players.ContainsKey ((int)data ["userid"])) {
					WeaponFiredEventArgs fire = new WeaponFiredEventArgs ();
					fire.Shooter = parser.Players [(int)data ["userid"]];
					fire.Weapon = new Equipment ((string)data ["weapon"]);

					parser.RaiseWeaponFired (fire);<commit_msg>Improved performance by removing unnecessary code.<commit_after>﻿using DemoInfo.Messages;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DemoInfo.DP.Handler
{
    class GameEventHandler : IMessageParser
    {
        public bool TryApplyMessage(ProtoBuf.IExtensible message, DemoParser parser)
        {
            if (message is CSVCMsg_GameEventList)
            {
				parser.GEH_Descriptors = new Dictionary<int, CSVCMsg_GameEventList.descriptor_t>();

				foreach (var d in ((CSVCMsg_GameEventList)message).descriptors) {
					parser.GEH_Descriptors[d.eventid] = d;
				}

				return true;
            }

			var descriptors = parser.GEH_Descriptors;
			var blindPlayers = parser.GEH_BlindPlayers;

			if (descriptors == null)
				return false;

			var rawEvent = message as CSVCMsg_GameEvent;
			if (rawEvent == null)
				return false;

            var eventDescriptor = descriptors[rawEvent.eventid];

			if (eventDescriptor.name == "round_start")
				parser.RaiseRoundStart();

			if (eventDescriptor.name == "round_announce_match_start")
				parser.RaiseMatchStarted();


			Dictionary<string, object> data;
			switch (eventDescriptor.name) {
			case "weapon_fire":
				data = MapData (eventDescriptor, rawEvent);

				if (parser.Players.ContainsKey ((int)data ["userid"])) {
					WeaponFiredEventArgs fire = new WeaponFiredEventArgs ();
					fire.Shooter = parser.Players [(int)data ["userid"]];
					fire.Weapon = new Equipment ((string)data ["weapon"]);

					parser.RaiseWeaponFired (fire);
{'fraction_non_alphanumeric': 0.10342698363692497, 'fraction_numerical': 0.0, 'mean_word_length': 3.608819345661451, 'pattern_counts': {'":': 2, '<': 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': '7472484', 'n_tokens_mistral': 1150, 'n_tokens_neox': 974, 'n_words': 219}