<commit_before>﻿using SRPCommon.UserProperties;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reactive;
using System.Reactive.Linq;

namespace SRPRendering
{
	class ScalarShaderVariableUserProperty<T> : IScalarProperty<T> where T : struct
	{
		private readonly IEnumerable<IShaderVariable> _variables;
		int _componentIndex;

		public ScalarShaderVariableUserProperty(IEnumerable<IShaderVariable> variables, int componentIndex)
		{
			_variables = variables;
			_componentIndex = componentIndex;

			// Different variables may have different defaults,
			// so force them all to the same value now.
			var firstValue = variables.First().GetComponent<T>(componentIndex);
			foreach (var variable in variables.Skip(1))
			{
				variable.SetComponent(_componentIndex, firstValue);
			}
		}

		public bool IsReadOnly => false;
		public string Name => _variables.First().Name;

		public Type Type => typeof(T);

		public T Value
		{
			get
			{
				// Assume everything has the same value.
				return _variables.First().GetComponent<T>(_componentIndex);
			}
			set
			{
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
				if (EqualityComparer<T>.Default.Equals(value, Value))
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
				{
					// Set on all variables.
					foreach (var variable in _variables)
					{
						variable.SetComponent(_componentIndex, value);
					}
				}
			}
		}

		public IDisposable Subscribe(IObserver<Unit> observer)
		{
			return _variables.Merge().Subscribe(observer);
		}
	}
}<commit_msg>Fix stupidity<commit_after>﻿using SRPCommon.UserProperties;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reactive;
using System.Reactive.Linq;

namespace SRPRendering
{
	class ScalarShaderVariableUserProperty<T> : IScalarProperty<T> where T : struct
	{
		private readonly IEnumerable<IShaderVariable> _variables;
		int _componentIndex;

		public ScalarShaderVariableUserProperty(IEnumerable<IShaderVariable> variables, int componentIndex)
		{
			_variables = variables;
			_componentIndex = componentIndex;

			// Different variables may have different defaults,
			// so force them all to the same value now.
			var firstValue = variables.First().GetComponent<T>(componentIndex);
			foreach (var variable in variables.Skip(1))
			{
				variable.SetComponent(_componentIndex, firstValue);
			}
		}

		public bool IsReadOnly => false;
		public string Name => _variables.First().Name;

		public Type Type => typeof(T);

		public T Value
		{
			get
			{
				// Assume everything has the same value.
				return _variables.First().GetComponent<T>(_componentIndex);
			}
			set
			{
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
				if (!EqualityComparer<T>.Default.Equals(value, Value))
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
				{
					// Set on all variables.
					foreach (var variable in _variables)
					{
						variable.SetComponent(_componentIndex, value);
					}
				}
			}
		}

		public IDisposable Subscribe(IObserver<Unit> observer)
		{
			return _variables.Merge().Subscribe(observer);
		}
	}
}
{'fraction_non_alphanumeric': 0.08897428318060893, 'fraction_numerical': 0.0053207212533254505, 'mean_word_length': 4.005917159763314, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, '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': '4256622', 'n_tokens_mistral': 1131, 'n_tokens_neox': 935, 'n_words': 267}