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

namespace Grace.Utilities
{
    /// <summary>
    /// Static class for generating unique id within the process space
    /// </summary>
    public static class UniqueStringId
    {
        private static readonly ThreadLocal<Random> _local = new ThreadLocal<Random>(() => new Random());
        private static int _counter;

        /// <summary>
        /// Generate string that is unique to this process
        /// </summary>
        /// <returns></returns>
        public static string Generate()
        {
            var intValue = _local.Value.Next();

            var builder = new StringBuilder();

            builder.Append((char)(intValue % 95 + 32));

            intValue = intValue >> 7;
            builder.Append((char)(intValue % 95 + 32));

            intValue = intValue >> 7;
            builder.Append((char)(intValue % 95 + 32));

            intValue = intValue >> 7;
            builder.Append((char)(intValue % 95 + 32));

            builder.Append(Interlocked.Increment(ref _counter));

            return builder.ToString();
        }
    }
}<commit_msg>simplifying generate method<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Grace.Utilities
{
    /// <summary>
    /// Static class for generating unique id within the process space
    /// </summary>
    public static class UniqueStringId
    {
        private static readonly ThreadLocal<Random> _local = new ThreadLocal<Random>(() => new Random());
        private static int _counter;

        /// <summary>
        /// Generate string that is unique to this process
        /// </summary>
        /// <returns></returns>
        public static string Generate()
        {
            var intValue = _local.Value.Next();
            
            return new string(new[]
            {
                (char)(intValue % 95 + 32),
                (char)((intValue >> 7) % 95 + 32),
                (char)((intValue >> 14) % 95 + 32),
                (char)((intValue >> 21) % 95 + 32)
            }) 
            + Interlocked.Increment(ref _counter);
        }
    }
}
{'fraction_non_alphanumeric': 0.12156357388316151, 'fraction_numerical': 0.01718213058419244, 'mean_word_length': 1.9782608695652173, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 33, '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': '959268', 'n_tokens_mistral': 638, 'n_tokens_neox': 588, 'n_words': 173}