<commit_before>﻿// <copyright file="GfxTile.cs" company="Public Domain">
//     Copyright (c) 2017 <NAME>.
// </copyright>

using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace Snes
{
    public struct GfxTile
    {
        public const int DotsPerPlane = 8;
        public const int PlanesPerTile = DotsPerPlane;
        public const int DotsPerTile = DotsPerPlane * PlanesPerTile;
        public const int SizeOf = DotsPerTile * sizeof(byte);

        public unsafe fixed byte Components[DotsPerTile];

        public byte this[int index]
        {
            get
            {
                unsafe
                {
                    fixed (byte* ptr = Components)
                    {
                        return ptr[index];
                    }
                }
            }

            set
            {
                unsafe
                {
                    fixed (byte* ptr = Components)
                    {
                        ptr[index] = value;
                    }
                }
            }
        }

        public GfxTile(byte[] data, int index, GraphicsFormat format)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            if (index < 0)<commit_msg>Bounds check in this[] accessor<commit_after>﻿// <copyright file="GfxTile.cs" company="Public Domain">
//     Copyright (c) 2017 <NAME>.
// </copyright>

using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace Snes
{
    public struct GfxTile
    {
        public const int DotsPerPlane = 8;
        public const int PlanesPerTile = DotsPerPlane;
        public const int DotsPerTile = DotsPerPlane * PlanesPerTile;
        public const int SizeOf = DotsPerTile * sizeof(byte);

        public unsafe fixed byte Components[DotsPerTile];

        public byte this[int index]
        {
            get
            {
                if ((uint)index >= (uint)DotsPerTile)
                {
                    throw new ArgumentOutOfRangeException(nameof(index));
                }

                unsafe
                {
                    fixed (byte* ptr = Components)
                    {
                        return ptr[index];
                    }
                }
            }

            set
            {
                if ((uint)index >= (uint)DotsPerTile)
                {
                    throw new ArgumentOutOfRangeException(nameof(index));
                }

                unsafe
                {
                    fixed (byte* ptr = Components)
                    {
                        ptr[index] = value;
                    }
                }
            }
        }

        public GfxTile(byte[] data, int index, GraphicsFormat format)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            if (index < 0)
{'fraction_non_alphanumeric': 0.07892976588628763, 'fraction_numerical': 0.004013377926421404, 'mean_word_length': 1.1167728237791932, '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': '3775622', 'n_tokens_mistral': 777, 'n_tokens_neox': 711, 'n_words': 183}