<commit_before>﻿using LmpClient.Base;
using LmpClient.Base.Interface;
using LmpClient.Network;
using LmpClient.Systems.TimeSyncer;
using LmpCommon.Message.Client;
using LmpCommon.Message.Data.Vessel;
using LmpCommon.Message.Interface;
using System;
using UniLinq;

namespace LmpClient.Systems.VesselSyncSys
{
    public class VesselSyncMessageSender : SubSystem<VesselSyncSystem>, IMessageSender
    {
        public void SendMessage(IMessageData msg)
        {
            NetworkSender.QueueOutgoingMessage(MessageFactory.CreateNew<VesselCliMsg>(msg));
        }
        
        public void SendVesselsSyncMsg()
        {
            var msgData = NetworkMain.CliMsgFactory.CreateNewMessageData<VesselSyncMsgData>();
            msgData.GameTime = TimeSyncerSystem.UniversalTime;

            var vesselIds = FlightGlobals.Vessels.Where(v=> v!= null).Select(v => v.id).ToArray();
            msgData.VesselsCount = vesselIds.Length;

            //Always clear the array just for safety...
            for (var i = 0; i < msgData.VesselIds.Length; i++)
            {
                msgData.VesselIds[i] = Guid.Empty;
            }

            if (msgData.VesselIds.Length < msgData.VesselsCount)
                Array.Resize(ref msgData.VesselIds, msgData.VesselsCount);

            Array.Copy(vesselIds, msgData.VesselIds, msgData.VesselsCount);

            SendMessage(msgData);
        }
    }
}<commit_msg>Avoid resize<commit_after>﻿using LmpClient.Base;
using LmpClient.Base.Interface;
using LmpClient.Network;
using LmpClient.Systems.TimeSyncer;
using LmpCommon.Message.Client;
using LmpCommon.Message.Data.Vessel;
using LmpCommon.Message.Interface;
using System;
using UniLinq;

namespace LmpClient.Systems.VesselSyncSys
{
    public class VesselSyncMessageSender : SubSystem<VesselSyncSystem>, IMessageSender
    {
        public void SendMessage(IMessageData msg)
        {
            NetworkSender.QueueOutgoingMessage(MessageFactory.CreateNew<VesselCliMsg>(msg));
        }
        
        public void SendVesselsSyncMsg()
        {
            var msgData = NetworkMain.CliMsgFactory.CreateNewMessageData<VesselSyncMsgData>();
            msgData.GameTime = TimeSyncerSystem.UniversalTime;

            var vesselIds = FlightGlobals.Vessels.Where(v=> v!= null).Select(v => v.id).ToArray();
            msgData.VesselsCount = vesselIds.Length;

            //Always clear the array just for safety...
            for (var i = 0; i < msgData.VesselIds.Length; i++)
            {
                msgData.VesselIds[i] = Guid.Empty;
            }

            if (msgData.VesselIds.Length < msgData.VesselsCount)
                msgData.VesselIds = new Guid[msgData.VesselsCount];

            Array.Copy(vesselIds, msgData.VesselIds, msgData.VesselsCount);

            SendMessage(msgData);
        }
    }
}
{'fraction_non_alphanumeric': 0.09518754423213022, 'fraction_numerical': 0.0007077140835102619, 'mean_word_length': 2.633676092544987, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '6611691', 'n_tokens_mistral': 883, 'n_tokens_neox': 830, 'n_words': 145}