<commit_before>﻿using System;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;

namespace NDbfReader
{
    /// <summary>
    /// Represents a <see cref="decimal"/> column.
    /// </summary>
    [DebuggerDisplay("Decimal {Name}")]
    public class DecimalColumn : Column<decimal?>
    {
        private static readonly NumberFormatInfo DecimalNumberFormat = new NumberFormatInfo { NumberDecimalSeparator = "." };

        /// <summary>
        /// Initializes a new instance with the specified name and offset.
        /// </summary>
        /// <param name="name">The column name.</param>
        /// <param name="offset">The column offset in a row in bytes.</param>
        /// <param name="size">The column size in bytes.</param>
        /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c> or empty.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="offset"/> is &lt; 0 or <paramref name="size"/> is &lt; 0.</exception>
        public DecimalColumn(string name, int offset, int size)
            : base(name, offset, size)
        {
        }

        /// <summary>
        /// Loads a value from the specified buffer.
        /// </summary>
        /// <param name="buffer">The byte array from which a value should be loaded. The buffer length is always at least equal to the column size.</param>
        /// <param name="offset">The byte offset in <paramref name="buffer"/> at which loading begins. </param>
        /// <param name="encoding">The encoding that should be used when loading a value. The encoding is never <c>null</c>.</param>
        /// <returns>A column value.</returns>
        protected override decimal? DoLoad(byte[] buffer, int offset, Encoding encoding)
        {
            string stringValue = encoding.GetString(buffer, offset, Size);
            if (stringValue.Length == 0)
            {
                return null;
            }

            char lastChar = stringValue.Last();
            if (lastChar == ' ' || lastChar == '?')
            {
                return null;
            }
            return decimal.Parse(stringValue, NumberStyles.Float | NumberStyles.AllowLeadingWhite, DecimalNumberFormat);
        }
    }
}<commit_msg>Remove "Last" LINQ method call in Load decimal method.<commit_after>﻿using System;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;

namespace NDbfReader
{
    /// <summary>
    /// Represents a <see cref="decimal"/> column.
    /// </summary>
    [DebuggerDisplay("Decimal {Name}")]
    public class DecimalColumn : Column<decimal?>
    {
        private static readonly NumberFormatInfo DecimalNumberFormat = new NumberFormatInfo { NumberDecimalSeparator = "." };

        /// <summary>
        /// Initializes a new instance with the specified name and offset.
        /// </summary>
        /// <param name="name">The column name.</param>
        /// <param name="offset">The column offset in a row in bytes.</param>
        /// <param name="size">The column size in bytes.</param>
        /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c> or empty.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="offset"/> is &lt; 0 or <paramref name="size"/> is &lt; 0.</exception>
        public DecimalColumn(string name, int offset, int size)
            : base(name, offset, size)
        {
        }

        /// <summary>
        /// Loads a value from the specified buffer.
        /// </summary>
        /// <param name="buffer">The byte array from which a value should be loaded. The buffer length is always at least equal to the column size.</paramm>
        /// <param name="offset">The byte offset in <paramref name="buffer"/> at which loading begins. </param>
        /// <param name="encoding">The encoding that should be used when loading a value. The encoding is never <c>null</c>.</param>
        /// <returns>A column value.</returns>
        protected override decimal? DoLoad(byte[] buffer, int offset, Encoding encoding)
        {
            string stringValue = encoding.GetString(buffer, offset, Size);
            if (stringValue.Length == 0)
            {
                return null;
            }

            char lastChar = stringValue[stringValue.Length - 1];
            if (lastChar == ' ' || lastChar == '?')
            {
                return null;
            }
            return decimal.Parse(stringValue, NumberStyles.Float | NumberStyles.AllowLeadingWhite, DecimalNumberFormat);
        }
    }
}
{'fraction_non_alphanumeric': 0.12972972972972974, 'fraction_numerical': 0.0015135135135135136, 'mean_word_length': 2.3113815318539728, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 71, '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': '7120064', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1176, 'n_words': 385}